Getting error while invoking API using AWS Lambda. (AWS Lambda + AWS API Gateway+ Postman)












-1















I get an error while invoking the AWS SageMaker endpoint API from a Lambda function. When I call this using Postman, I am getting an error like:



{
"errorMessage": "module initialization error"
}









share|improve this question

























  • this is what many of us have encountered and many questions are present on stackOverflow about it also - it would help if you share the URL of the exact API call with the data that you are sending to API gateway

    – Akber Iqbal
    Nov 22 '18 at 5:40
















-1















I get an error while invoking the AWS SageMaker endpoint API from a Lambda function. When I call this using Postman, I am getting an error like:



{
"errorMessage": "module initialization error"
}









share|improve this question

























  • this is what many of us have encountered and many questions are present on stackOverflow about it also - it would help if you share the URL of the exact API call with the data that you are sending to API gateway

    – Akber Iqbal
    Nov 22 '18 at 5:40














-1












-1








-1








I get an error while invoking the AWS SageMaker endpoint API from a Lambda function. When I call this using Postman, I am getting an error like:



{
"errorMessage": "module initialization error"
}









share|improve this question
















I get an error while invoking the AWS SageMaker endpoint API from a Lambda function. When I call this using Postman, I am getting an error like:



{
"errorMessage": "module initialization error"
}






amazon-web-services aws-lambda amazon-sagemaker






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 15:55









Praneeth Peiris

1,104726




1,104726










asked Nov 22 '18 at 5:31









Ashish JangirAshish Jangir

12




12













  • this is what many of us have encountered and many questions are present on stackOverflow about it also - it would help if you share the URL of the exact API call with the data that you are sending to API gateway

    – Akber Iqbal
    Nov 22 '18 at 5:40



















  • this is what many of us have encountered and many questions are present on stackOverflow about it also - it would help if you share the URL of the exact API call with the data that you are sending to API gateway

    – Akber Iqbal
    Nov 22 '18 at 5:40

















this is what many of us have encountered and many questions are present on stackOverflow about it also - it would help if you share the URL of the exact API call with the data that you are sending to API gateway

– Akber Iqbal
Nov 22 '18 at 5:40





this is what many of us have encountered and many questions are present on stackOverflow about it also - it would help if you share the URL of the exact API call with the data that you are sending to API gateway

– Akber Iqbal
Nov 22 '18 at 5:40












3 Answers
3






active

oldest

votes


















0














Just to make it clear, you can't call SageMaker endpoints directly using PostMan (even if it is, it would not be straightforward).
You may need to use AWS SDK (i.e. boto) for that.



Ref : https://aws.amazon.com/blogs/machine-learning/call-an-amazon-sagemaker-model-endpoint-using-amazon-api-gateway-and-aws-lambda/



What I would suggest is to create a small HTTP server with Flask and use the AWS SDK (Boto) to call the endpoint. Then you can call your Flask endpoint using PostMan.






share|improve this answer































    0














    We recommend using AWS SDK to invoke your endpoint. AWS SDK clients handle the serialization for you as well as request signing, etc. It would be really hard to get it right manually with postman.



    We have the SDK client available in many languages, including Java, Python, JS, etc.
    https://docs.aws.amazon.com/sagemaker/latest/dg/API_runtime_InvokeEndpoint.html#API_runtime_InvokeEndpoint_SeeAlso






    share|improve this answer































      0














      Next time please include more details in your question. eg. POST request data, Headers etc.



      Anyways, to help you out in calling Sagemaker endpoint using Postman -




      1. In 'Authorization' tab, select type as 'AWS Signature'.

      2. Enter your Access and Secret key of the IAM user which has permission to Sagemaker resources.

      3. Enter the AWS region. eg.us-east-1

      4. Enter 'Service Name' as 'sagemaker'

      5. Select the right content type. Some ML algorithms only accept 'text/csv'.

      6. Select request type as 'POST'

      7. Enter the Sagemaker Invocation url. eg:'https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/xgboost-xxxx-xx-xx-xx-xx-xx-xxx/invocations'


      Try it out and let me know if you have any issues.



      Here is how your Postman should look -
      Sagemaker endpoint request - Postman Screenshot






      share|improve this answer


























      • @praneeth-peiris Have a look. You can call Sagemaker endpoint using Postman.

        – Priyank Kapasi
        Nov 26 '18 at 5:38











      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424429%2fgetting-error-while-invoking-api-using-aws-lambda-aws-lambda-aws-api-gateway%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Just to make it clear, you can't call SageMaker endpoints directly using PostMan (even if it is, it would not be straightforward).
      You may need to use AWS SDK (i.e. boto) for that.



      Ref : https://aws.amazon.com/blogs/machine-learning/call-an-amazon-sagemaker-model-endpoint-using-amazon-api-gateway-and-aws-lambda/



      What I would suggest is to create a small HTTP server with Flask and use the AWS SDK (Boto) to call the endpoint. Then you can call your Flask endpoint using PostMan.






      share|improve this answer




























        0














        Just to make it clear, you can't call SageMaker endpoints directly using PostMan (even if it is, it would not be straightforward).
        You may need to use AWS SDK (i.e. boto) for that.



        Ref : https://aws.amazon.com/blogs/machine-learning/call-an-amazon-sagemaker-model-endpoint-using-amazon-api-gateway-and-aws-lambda/



        What I would suggest is to create a small HTTP server with Flask and use the AWS SDK (Boto) to call the endpoint. Then you can call your Flask endpoint using PostMan.






        share|improve this answer


























          0












          0








          0







          Just to make it clear, you can't call SageMaker endpoints directly using PostMan (even if it is, it would not be straightforward).
          You may need to use AWS SDK (i.e. boto) for that.



          Ref : https://aws.amazon.com/blogs/machine-learning/call-an-amazon-sagemaker-model-endpoint-using-amazon-api-gateway-and-aws-lambda/



          What I would suggest is to create a small HTTP server with Flask and use the AWS SDK (Boto) to call the endpoint. Then you can call your Flask endpoint using PostMan.






          share|improve this answer













          Just to make it clear, you can't call SageMaker endpoints directly using PostMan (even if it is, it would not be straightforward).
          You may need to use AWS SDK (i.e. boto) for that.



          Ref : https://aws.amazon.com/blogs/machine-learning/call-an-amazon-sagemaker-model-endpoint-using-amazon-api-gateway-and-aws-lambda/



          What I would suggest is to create a small HTTP server with Flask and use the AWS SDK (Boto) to call the endpoint. Then you can call your Flask endpoint using PostMan.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 17:13









          Praneeth PeirisPraneeth Peiris

          1,104726




          1,104726

























              0














              We recommend using AWS SDK to invoke your endpoint. AWS SDK clients handle the serialization for you as well as request signing, etc. It would be really hard to get it right manually with postman.



              We have the SDK client available in many languages, including Java, Python, JS, etc.
              https://docs.aws.amazon.com/sagemaker/latest/dg/API_runtime_InvokeEndpoint.html#API_runtime_InvokeEndpoint_SeeAlso






              share|improve this answer




























                0














                We recommend using AWS SDK to invoke your endpoint. AWS SDK clients handle the serialization for you as well as request signing, etc. It would be really hard to get it right manually with postman.



                We have the SDK client available in many languages, including Java, Python, JS, etc.
                https://docs.aws.amazon.com/sagemaker/latest/dg/API_runtime_InvokeEndpoint.html#API_runtime_InvokeEndpoint_SeeAlso






                share|improve this answer


























                  0












                  0








                  0







                  We recommend using AWS SDK to invoke your endpoint. AWS SDK clients handle the serialization for you as well as request signing, etc. It would be really hard to get it right manually with postman.



                  We have the SDK client available in many languages, including Java, Python, JS, etc.
                  https://docs.aws.amazon.com/sagemaker/latest/dg/API_runtime_InvokeEndpoint.html#API_runtime_InvokeEndpoint_SeeAlso






                  share|improve this answer













                  We recommend using AWS SDK to invoke your endpoint. AWS SDK clients handle the serialization for you as well as request signing, etc. It would be really hard to get it right manually with postman.



                  We have the SDK client available in many languages, including Java, Python, JS, etc.
                  https://docs.aws.amazon.com/sagemaker/latest/dg/API_runtime_InvokeEndpoint.html#API_runtime_InvokeEndpoint_SeeAlso







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 23 '18 at 20:56









                  Han WangHan Wang

                  11




                  11























                      0














                      Next time please include more details in your question. eg. POST request data, Headers etc.



                      Anyways, to help you out in calling Sagemaker endpoint using Postman -




                      1. In 'Authorization' tab, select type as 'AWS Signature'.

                      2. Enter your Access and Secret key of the IAM user which has permission to Sagemaker resources.

                      3. Enter the AWS region. eg.us-east-1

                      4. Enter 'Service Name' as 'sagemaker'

                      5. Select the right content type. Some ML algorithms only accept 'text/csv'.

                      6. Select request type as 'POST'

                      7. Enter the Sagemaker Invocation url. eg:'https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/xgboost-xxxx-xx-xx-xx-xx-xx-xxx/invocations'


                      Try it out and let me know if you have any issues.



                      Here is how your Postman should look -
                      Sagemaker endpoint request - Postman Screenshot






                      share|improve this answer


























                      • @praneeth-peiris Have a look. You can call Sagemaker endpoint using Postman.

                        – Priyank Kapasi
                        Nov 26 '18 at 5:38
















                      0














                      Next time please include more details in your question. eg. POST request data, Headers etc.



                      Anyways, to help you out in calling Sagemaker endpoint using Postman -




                      1. In 'Authorization' tab, select type as 'AWS Signature'.

                      2. Enter your Access and Secret key of the IAM user which has permission to Sagemaker resources.

                      3. Enter the AWS region. eg.us-east-1

                      4. Enter 'Service Name' as 'sagemaker'

                      5. Select the right content type. Some ML algorithms only accept 'text/csv'.

                      6. Select request type as 'POST'

                      7. Enter the Sagemaker Invocation url. eg:'https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/xgboost-xxxx-xx-xx-xx-xx-xx-xxx/invocations'


                      Try it out and let me know if you have any issues.



                      Here is how your Postman should look -
                      Sagemaker endpoint request - Postman Screenshot






                      share|improve this answer


























                      • @praneeth-peiris Have a look. You can call Sagemaker endpoint using Postman.

                        – Priyank Kapasi
                        Nov 26 '18 at 5:38














                      0












                      0








                      0







                      Next time please include more details in your question. eg. POST request data, Headers etc.



                      Anyways, to help you out in calling Sagemaker endpoint using Postman -




                      1. In 'Authorization' tab, select type as 'AWS Signature'.

                      2. Enter your Access and Secret key of the IAM user which has permission to Sagemaker resources.

                      3. Enter the AWS region. eg.us-east-1

                      4. Enter 'Service Name' as 'sagemaker'

                      5. Select the right content type. Some ML algorithms only accept 'text/csv'.

                      6. Select request type as 'POST'

                      7. Enter the Sagemaker Invocation url. eg:'https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/xgboost-xxxx-xx-xx-xx-xx-xx-xxx/invocations'


                      Try it out and let me know if you have any issues.



                      Here is how your Postman should look -
                      Sagemaker endpoint request - Postman Screenshot






                      share|improve this answer















                      Next time please include more details in your question. eg. POST request data, Headers etc.



                      Anyways, to help you out in calling Sagemaker endpoint using Postman -




                      1. In 'Authorization' tab, select type as 'AWS Signature'.

                      2. Enter your Access and Secret key of the IAM user which has permission to Sagemaker resources.

                      3. Enter the AWS region. eg.us-east-1

                      4. Enter 'Service Name' as 'sagemaker'

                      5. Select the right content type. Some ML algorithms only accept 'text/csv'.

                      6. Select request type as 'POST'

                      7. Enter the Sagemaker Invocation url. eg:'https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/xgboost-xxxx-xx-xx-xx-xx-xx-xxx/invocations'


                      Try it out and let me know if you have any issues.



                      Here is how your Postman should look -
                      Sagemaker endpoint request - Postman Screenshot







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 26 '18 at 5:39

























                      answered Nov 26 '18 at 5:31









                      Priyank KapasiPriyank Kapasi

                      76821024




                      76821024













                      • @praneeth-peiris Have a look. You can call Sagemaker endpoint using Postman.

                        – Priyank Kapasi
                        Nov 26 '18 at 5:38



















                      • @praneeth-peiris Have a look. You can call Sagemaker endpoint using Postman.

                        – Priyank Kapasi
                        Nov 26 '18 at 5:38

















                      @praneeth-peiris Have a look. You can call Sagemaker endpoint using Postman.

                      – Priyank Kapasi
                      Nov 26 '18 at 5:38





                      @praneeth-peiris Have a look. You can call Sagemaker endpoint using Postman.

                      – Priyank Kapasi
                      Nov 26 '18 at 5:38


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424429%2fgetting-error-while-invoking-api-using-aws-lambda-aws-lambda-aws-api-gateway%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Feedback on college project

                      Futebolista

                      Albești (Vaslui)