Curl "No status code specified in the response"

Sarps-Mac $ curl -vvv -X GET "https://jmd88pxp.execute-api.us-west-2.amazonaws.com/dev/user?limit=10"
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 54.192.119.190...
* Connected to jmd88pxp.execute-api.us-west-2.amazonaws.com (54.192.119.180) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.execute-api.us-west-2.amazonaws.com
* Server certificate: Symantec Class 3 Secure Server CA - G4
* Server certificate: VeriSign Class 3 Public Primary Certification Authority - G5
> GET /dev/user?limit=10 HTTP/1.1
> Host: jmd88pxp.execute-api.us-west-2.amazonaws.com
> User-Agent: curl/7.49.1
> Accept: */*
< HTTP/1.1 502 Bad Gateway
< Content-Type: application/json
< Content-Length: 36
< Connection: keep-alive
< Date: Sun, 18 Dec 2016 00:54:14 GMT
< X-Cache: Error from cloudfront
< Via: 1.1 66ed69e8b47ad05050331602c798133a.cloudfront.net (CloudFront)

You need to provide a status code

const RESPONSE = {
  OK: {
    statusCode: 200,
    message: [],
  },
  ERROR: {
    status: 400,
    message: "Something went wrong. Please try again."
  }
};

Then your call will return successfully


Sarps-MacBook-Pro:serverless-framework sarp$ curl -vvv -X GET "https://jmd88pxp.execute-api.us-west-2.amazonaws.com/dev/user?limit=10"
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 54.192.119.31...
* Connected to jmd88pxp.execute-api.us-west-2.amazonaws.com (54.192.119.31) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.execute-api.us-west-2.amazonaws.com
* Server certificate: Symantec Class 3 Secure Server CA - G4
* Server certificate: VeriSign Class 3 Public Primary Certification Authority - G5
> GET /dev/user?limit=10 HTTP/1.1
> Host: jmd88pxp.execute-api.us-west-2.amazonaws.com
> User-Agent: curl/7.49.1
> Accept: */*
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 0
< Connection: keep-alive
< Date: Sun, 18 Dec 2016 01:43:52 GMT
< X-Cache: Miss from cloudfront
* Connection #0 to host jmd88pxp.execute-api.us-west-2.amazonaws.com left intact

Comments

Unknown said…
Wow, absolutely fantastic blog. I am very glad to have such useful information. Thanks. For more information visit legal herbal empire for sale
rmouniak said…
This comment has been removed by the author.

Popular posts from this blog

AWS encryption chart (SSE-S3 vs SSE-KMS vs SSE-C)

Space Character Problem on IE 6, 7, and 8

Sending Large Data with JSON