Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cy.request fails with error incorrect header check #3971

Closed
kundaiAtPropertyMe opened this issue Apr 16, 2019 · 3 comments
Closed

cy.request fails with error incorrect header check #3971

kundaiAtPropertyMe opened this issue Apr 16, 2019 · 3 comments

Comments

@kundaiAtPropertyMe
Copy link

kundaiAtPropertyMe commented Apr 16, 2019

Current behavior:

I'm calling an API endpoint to run test by cy.request,

here is my request code

cy.request({
      method: 'POST',
      url: Cypress.config().baseApiUrl ,                
      body:{
          TestUser: testUser
      }
  }) .then((response) =>{
      console.log(response);
  });

When I try use Postman to verify it then I get correct result in a 200 with a json response.

{
    "CustomerId":"00000000-0000-0000-0000-000000000000",
    "ResponseStatus":null,
    "IsSuccessful":true
}

but cy.request returns error

CypressError: cy.request() failed trying to load:

We attempted to make an http request to this URL but the request failed without a response.

We received this error at the network level:

  > Error: incorrect header check

Desired behavior:

cy.request should return a 200 for this request

Extra information

The response header likes

Cache-Control →private
Content-Length →68
Content-Type →application/json; charset=utf-8
Content-Encoding →deflate
Vary →Accept
Server →Microsoft-IIS/10.0
X-SourceFiles →=?UTF-8?B?QzpcRGV2ZWxvcG1lbnRcUE1ccE0uQXBpSG9zdFxhcGlcdGVzdFxwb3J0Zm9saW9cbmV3?=
X-Powered-By →ASP.NET
Date →Tue, 16 Apr 2019 02:40:44 GMT

Complete error output

CypressError: cy.request() failed trying to load:

http://xxxx

We attempted to make an http request to this URL but the request failed without a response.

We received this error at the network level:

  > Error: incorrect header check

-----------------------------------------------------------

The request we sent was:

Method: POST
URL: http://xxxx

-----------------------------------------------------------

Common situations why this would fail:
  - you don't have internet access
  - you forgot to run / boot your web server
  - your web server isn't accessible
  - you have weird network configuration settings on your computer

The stack trace for this error is:

RequestError: Error: incorrect header check
    at new RequestError (C:\Users\Kun\AppData\Local\Cypress\Cache\3.2.0\Cypress\resources\app\packages\server\node_modules\request-promise-core\lib\errors.js:14:15)
    at Request.plumbing.callback (C:\Users\Kun\AppData\Local\Cypress\Cache\3.2.0\Cypress\resources\app\packages\server\node_modules\request-promise-core\lib\plumbing.js:87:29)
    at Request.RP$callback [as _callback] (C:\Users\Kun\AppData\Local\Cypress\Cache\3.2.0\Cypress\resources\app\packages\server\node_modules\request-promise-core\lib\plumbing.js:46:31)
    at self.callback (C:\Users\Kun\AppData\Local\Cypress\Cache\3.2.0\Cypress\resources\app\packages\server\node_modules\request\request.js:185:22)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at Inflate.<anonymous> (C:\Users\Kun\AppData\Local\Cypress\Cache\3.2.0\Cypress\resources\app\packages\server\node_modules\request\request.js:1086:12)
    at emitOne (events.js:120:20)
    at Inflate.emit (events.js:210:7)
    at Inflate.zlibOnError (zlib.js:155:8)

Versions

Cypress version 3.2.0

@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Apr 18, 2019
@jennifer-shehane jennifer-shehane added type: bug and removed stage: needs investigating Someone from Cypress needs to look at this labels Apr 18, 2019
@AlainPilon
Copy link

I am having the same issue.

@IanWalston
Copy link

IanWalston commented Sep 19, 2020

instead of this:

cy.request({
      method: 'POST',
      url: Cypress.config().baseApiUrl ,                
      body:{
          TestUser: testUser
      }
  })

use this:

cy.request('POST', Cypress.config().baseApiUrl, {TestUser: testUser})

for more information about the cy.request() method: https://docs.cypress.io/api/commands/request.html#Syntax

@jennifer-shehane
Copy link
Member

I wasn't able to reproduce the issue with the information provided. We'll have to close this issue until we can reproduce it. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.

Please comment in this issue with a reproducible example and we will consider reopening the issue. Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants