3

I'm desperately trying to find out how to change mapping template for integration request in POST request in API Gateway with PHP SDK v3. I've googled for hours and it seems there's no further documentation for that, nothing. The only thing is official AWS documentation for that. and it's very brief.

It seems really simple - let's call an update method, fill a new application/json response in it and we're done - but - there are available four candidate API methods for doing that: UpdateMethod, UpdateMethodResponse, UpdateIntegration, UpdateIntegrationResponse and for all of them there is the same documentation:

$result = $client->update<whatever>([
'httpMethod' => '<string>', // REQUIRED
'patchOperations' => [
    [
        'from' => '<string>',
        'op' => 'add|remove|replace|move|copy|test',
        'path' => '<string>',
        'value' => '<string>',
    ],
    // ...
],
'resourceId' => '<string>', // REQUIRED
'restApiId' => '<string>', // REQUIRED

]);

So, does anyone knows:

  1. Which method is suitable for doing that
  2. What to fill in in these four 'universal' fields
  3. Have anybody ever done that through v3 API?

Any help is appreciated, thanks you very much.

1 Answer 1

3

Well, for anyone interested in that in future - after doing some research finally discovered the proper syntax. It references the AWS API universal update structure for which I, unfortunately, wasn't able to find documentation anywhere.

Hint: Analyse XHR request sent from your browser while working in AWS administration.

Assuming use of aws-php-sdk-v3:

$sdk->createApiGateway()->updateIntegration([
            'restApiId'=>'<your restApiId here>',
            'resourceId' => '<specific resource id here>',
            'httpMethod' => 'POST',
            'patchOperations' => [
                [
                    'op' => 'replace',
                    'path' => '/requestTemplates/application~1json',
                    'value' => '{"response":"Hello, Kitty!"}'
                ]
            ]
        ]);
  • The path parameter references a JSON-pointer string as described here
  • The op parameter is obvious enough - but when using copy or move there must be also from parameter with JSON-pointer to source filled in.
  • The value is just raw string you want to write somewhere.

Another possibilities and combinations are obvious.

Good luck!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.