Amazon APi gateway fails to generate transformed request

16,694

Solution 1

Please make sure your content-type what you defined in integration request template.

You can try this curl command.

curl -X POST https://aaaaaaa.execute-api.us-west-2.amazonaws.com/beta/apitest/xml -H "Content-Type: application/json" --data-binary "Articletext"

Solution 2

In my case the problem was that I did not Deploy the API, so it was not updated for external use. See Amazon API Gateway : response body is not transformed when the API is called via Postman?

Share:
16,694
Yawar
Author by

Yawar

I like to solve problems from the childhood. If someone comments about that specific target is hard to achieve then it triggers me to give it a try. That behaviour had improved my analytical skills and performance under pressure. I am a Computer Science graduate and having an experience of 7 years of programming in different platforms. I explored C#, ASP.net, PHP, Java, bash scripting, sql scripting, javascript, HTML, etc. Beside this I also sense continuous integration, auto scaling, load balancing, automated testing, NoSQL engines, WIX, NSIS.

Updated on June 04, 2022

Comments

  • Yawar
    Yawar almost 2 years

    I was trying the integration of Amazon API gateway with Lambda function. I was successfully able to achieve though but when I tried with curl it fails.

    Lambda method, API gateway integration along with template mapping under integration request are setup.

    When I run "test" from console, it works fine

    Execution log for request test-request 
    Wed Nov 04 07:27:30 UTC 2015 : Starting execution for request: test-invoke-request
    Wed Nov 04 07:27:30 UTC 2015 : API Key: test-invoke-api-key
    Wed Nov 04 07:27:30 UTC 2015 : Method request path: {service=xml}
    Wed Nov 04 07:27:30 UTC 2015 : Method request query string: {}
    Wed Nov 04 07:27:30 UTC 2015 : Method request headers: {}
    Wed Nov 04 07:27:30 UTC 2015 : Method request body before transformations: Articletext
    Wed Nov 04 07:27:30 UTC 2015 : Endpoint request body after transformations: {
      "prog" : "xml",
      "content" : "Articletext",
      "test" : "{path={service=xml}, querystring={}, header={}}"
    }
    

    but when I tries to access it through curl it is not able to create proper body after transformation

    curl -X POST https://aaaaaaa.execute-api.us-west-2.amazonaws.com/beta/apitest/xml -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" --data-binary "Articletext"

    Starting execution for request: 
    Method request path: {service=xml}
    Method request query string:
    {}
    Method request body before transformations: Articletext
    Endpoint request body after transformations: Articletext
    Endpoint response body before transformations:
    {
        "Type": "User",
        "message": "Could not parse request body into json."
    }
    

    Can any one suggest me about missing part?