Aws-sdk-js: APIGateway Put Integration still yields an error after update

Created on 30 Oct 2015  路  6Comments  路  Source: aws/aws-sdk-js

Hello!

{ [BadRequestException: Enumeration value for HttpMethod must be non-empty]
  message: 'Enumeration value for HttpMethod must be non-empty',
  code: 'BadRequestException',
  time: Fri Oct 30 2015 05:36:49 GMT-0400 (EDT),
  statusCode: 400,
  retryable: false,
  retryDelay: 30 } null

https://github.com/aws/aws-cli/issues/1605
https://github.com/boto/botocore/pull/706

The above references a fix for the above message, but it still is not working. The above issue was closed, so created this one specifically in reference to the SDK. Version used to reproduce is: 2.2.13

Example code to reproduce:

gate.putIntegration({
     httpMethod:'POST', 
     resourceId: '8oqq0x', 
     restApiId: 'r3wraomlb6', 
     type: 'AWS'
}, console.log);
documentation guidance

Most helpful comment

@raghunat
I know the documentation isn't very clear on this, but you're missing a few more parameters for the putIntegration method.
When you're specifying type: 'AWS', you also need to provide the integrationHttpMethod, the uri, and the credentials (execution role).
Before the fix referenced above was made, it wasn't possible to set the integrationHttpMethod.

The uri is probably the trickiest parameter to specify the first time around. There's clearer documentation on how to build the uri on the API Gateway docs here:
http://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#uri

So, if you wanted to call a lambda function, the uri would look something like this:
arn:aws.apigateway:{region}:lambda:path/2015-03-31/functions/{lambda function arn}

Let me know if this helps, or if you need further clarification.

All 6 comments

@raghunat
I know the documentation isn't very clear on this, but you're missing a few more parameters for the putIntegration method.
When you're specifying type: 'AWS', you also need to provide the integrationHttpMethod, the uri, and the credentials (execution role).
Before the fix referenced above was made, it wasn't possible to set the integrationHttpMethod.

The uri is probably the trickiest parameter to specify the first time around. There's clearer documentation on how to build the uri on the API Gateway docs here:
http://docs.aws.amazon.com/apigateway/api-reference/resource/integration/#uri

So, if you wanted to call a lambda function, the uri would look something like this:
arn:aws.apigateway:{region}:lambda:path/2015-03-31/functions/{lambda function arn}

Let me know if this helps, or if you need further clarification.

@chrisradek

Thanks for the response! Yes the documentation then was very unclear :-)

Would it then be something like this?

gate.putIntegration({
     httpMethod:'POST', 
     resourceId: '8oqq0x', 
     restApiId: 'r3wraomlb6', 
     type: 'AWS',
     integrationHttpMethod: 'POST',
     uri: 'arn:aws.apigateway:us-east-1:lambda:path/2015-03-31/functions/myFunctionName',
     credentials: 'myFullyQualifiedLambdaRole'
}, console.log);

@raghunat
Yes, those parameters look correct. Just remember that in the uri, replace 'myFunctionName' with the full arn for your lambda function.

Let me know if that works, or if you're still having problems getting it to work.

I'm closing this issue, but feel free to comment here or re-open if you're still having issues.

The following line from the serverless application model examples helped me resolve this same issue, the uri is pretty tricky:

https://github.com/awslabs/serverless-application-model/blob/master/examples/2016-10-31/api_swagger_cors/swagger.yaml#L23

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings