I am trying to create a custom auth action for a custom integration. However i get the following error. I have tested the call in postman and all is working. Any advice as to what is wrong?
{ "message": "The requested resource was not found.", "code": "not.found", "status": 404, "messageParams": {}, "contextId": "7b9f975a-9829-415f-8fb9-4151bcac0661", "details": [ { "errorCode": "ACTION.REMOTE_ENDPOINT" } ], "errors": [ { "message": "REST call for action execute failed. Message:Request to backend service failed. Response from web service: [7b9f975a-9829-415f-8fb9-4151bcac0661]", "code": "NOT_FOUND", "status": 404, "messageParams": {}, "details": [], "errors": [] } ] }
This is the configuration, I am unable to upload the export { "requestUrlTemplate": "https://login.microsoftonline.com/${credentials.tenant}/oauth2/v2.0/token", "requestType": "POST", "headers": { "Authorization": "Basic $encoding.base64(\"${credentials.clientId}:${credentials.clientSecret}\")", "Content-Type": "application/x-www-form-urlencoded" }, "requestTemplate": "grant_type=client_credentials, scope=${credentials.scope}" }
I don't have access to a Microsoft platform where I could test a similar oauth request.
But I see at least one issue.
In your requestTemplate, I think the format is wrong (between grant_type and scope).
With "application/x-www-form-urlencoded", it should be an & separating the 2.
I mean "grant_type=client_credentials&scope=${credentials.scope}"
What surprises me is the error status you get back - 404.
So maybe there is something else as well.
As you are saying that it is working with Postman, I would suggest to open the Postman console (On Mac, it is in the View menu - Show Postman console).
Execute the request, select the entry in the Postman console AND select "Show raw log".
You will then see what Postman exactly sends.
As an example, when you add 2 variables in "application/x-www-form-urlencoded" body, postman will do 2 things automatically. Put them in a body with "&" as separator. And if one variable contains some content like http://something/abcd, it will automatically escape it (url encoding).
I agree with Jerome that escaping is one of the problems. I've attached a screenshot from the documentation.
In the red box, it explains that you should escape input and output variables, but that they are intentionally not escaped in the example below it for context reasons. If you based your request on one of our examples, it would have been easy to overlook that little note. I missed it the first time when researching this answer anyway.
Hope you get it fixed. Please let us know what happens when you make the changes! Good luck!
Thanks Ali and Jerome. I have had a look and change what you have suggested, the scope is a URL so that would have been causing issues however the same issue persists. I have changed all inputs to be escaped to ensure they are being treated correctly. Any other suggestions?
It looks like you are using $esc.jsonString inside of your URL, esc.url is probably the one you want to use.
When you run this action in test mode you should one of the steps is the URL after the template has been processed. Does the URL look as you would expect there?
One other thing to try when an endpoint is being weird is