Search code examples
aws-api-gatewayhttpie

HTTPIE 307 Temp Redirect - APIGATEWAY


I'm trying to get an AWS APIGateway implementation going, and am trying to send a request from the HTTPie module rather than from Postman. It works perfectly from Postman, but HTTPie doesn't seem to work for me, and only throws a 307 Temporary Redirect.

Using the following command:

http POST {userid}.execute-api.ap-southeast-2.amazonaws.com/sqstest/message name=john

Outputs:

HTTP/1.1 307 Temporary Redirect
Connection: keep-alive
Content-Length: 185
Content-Type: text/html
Date: Mon, 16 Apr 2018 06:28:24 GMT
Location: https://{userid}.execute-api.ap-southeast-2.amazonaws.com/sqstest/message
Server: CloudFront
Via: ################(CloudFront)
X-Amz-Cf-Id: ######################
X-Cache: Redirect from cloudfront

I did notice that Content-Type was text/html, which was odd considering I needed to send a json - but no matter what variant of the command I tried, it would still return the same results. From my understanding it should work the same as Postman as long as the headers are the same (they are minus the content-type, which doesn't change even if I define it using -j/--json).

Any help? Cheers.


Solution

  • After a few hours of trial-and-error, determined that the error was in syntax. Required a https:// on the command and to state it as json it needed a semicolon (:).

    For example:

    http POST https://{userid}.execute-api.ap-southeast-2.amazonaws.com/sqstest/message name:=john
    

    As opposed to the statement in the question.