my flow is I need to call an API to get the token and then call the actual API with that token.
I was able to get the token directly calling the token URL from postman without any issues. (screen grab below)
But when I am calling the same endpoint via apigee, I am getting 401 ( endpoint throwing 500).
I understand that I am doing something wrong in my service callout. (screen grabs below)
Postman call via proxy. (please observe I am sending my request details for the actual endpoint in the body)
Apigee Service call out
Apigee Trace Error:
Please let me know if you need more details?
Solved! Go to Solution.
It looks to me that
Have you tried to use x-www-form-urlencoded in the SC?
<ServiceCallout name='SC-1'> <Request> <Set> <Headers> <Header name='content-type'>application/x-www-form-urlencoded</Header> </Headers> <FormParams> <FormParam name='username'>godino@google.com</FormParam> <FormParam name='password'>ILoveAPIs</FormParam> <FormParam name='grant_type'>password</FormParam> <FormParam name='client_id'>ABCDEF</FormParam> <FormParam name='client_secret'>1234567</FormParam> </FormParams> <Verb>POST</Verb> </Set> </Request> <Response>SNPOCAuthResponse</Response> <HTTPTargetConnection> <SSLInfo> <Enabled>true</Enabled> <IgnoreValidationErrors>true</IgnoreValidationErrors> </SSLInfo> <Properties> <Property name='success.codes'>2xx, 3xx, 4xx, 5xx</Property> </Properties> <URL>https://myserver.com/oauth_token.do</URL> </HTTPTargetConnection> </ServiceCallout>
Anything inside the FormParam text element is treated as a message template, so you can refer to context variables by wrapping them in curlies like this:
<FormParam name='username'>{my_username}</FormParam>