I am trying to send a Woocommerce webhook to AWS API Gateway. When i put in my API Gateway URL on Amazon I get the following error:
Error: Delivery URL returned response code: 415
I think this is related to headers, there is an option to Create CORS in API-Gateway that I have now done. Which then adds an OPTION method but I still get undefined in Cloudwatch
I created a POST method and used the mapping template below with application/json and the setting When there are no templates defined (recommended)
{
"body" : $input.json('$'),
"headers": {
#foreach($header in $input.params().header.keySet())
"$header": "$util.escapeJavaScript($input.params().header.get($header))" #if ($foreach.hasNext), #end
#end
}
}
Here is a mini Lambda Node function that just outputs a Woocommerce order number to the console and shows in Cloudwatch whether the API passthrough is working.
exports.handler = (event, context, callback, err) => {
//callback(null, event.meta_data);
if (err) console.log('JSON Pass Fail'); // an error occurred
else console.log(event.order_key); // successful response
};
If anyone did want to have a go at re-creating this, you can knock up a quick Wordpress install on cPanel and install the Woocommerce Plugin. Setup a dummy product and then just use the Cash on Delivery as a payment method to get your "Order Created" webhooks firing. Only takes 2 minutes.
You can use https://requestbin.com/ or webhook.site to test out webhook outputs.
Can anyone help sorting out the Headers so i can pass a Woocommerce payload to API Gateway?