Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

API profile - POST request body

Hello,

I am creating an API profile for Feefo authentication - https://support.feefo.com/support/solutions/articles/8000041717-api-authentication.
It requires a POST request, sending several credential parameters in the body.

I found several examples, which indirectly show how to do that:
- https://redshiftsupport.matillion.com/customer/en/portal/articles/2836045-creating-api-profiles-support
- https://redshiftsupport.matillion.com/customer/en/portal/articles/2750444-authentication-with-api-profiles?b_id=8915

The relevant part of my script looks like this:

<rsb:set attr="uri" value="http://api.feefo.com/api/apiauthenticate" />
<rsb:script method="GET">
<rsb:set attr="method" value="POST" />
<rsb:set attr="data">
{
"authenticationDTO": {
"merchantIdentifier": "xxxxxxxxxx",
"username": "xxxx@xxxx.com",
"password": "xxxxxxx",
"apiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
</rsb:set>

<rsb:call op="jsonproviderGet">
<rsb:push />
</rsb:call>

</rsb:script>

Testing and running live fail with "No credentials provided" - this is the response when no body or incorrect body is passed.
After I found out about logging the API requests, I can see the body is url-encoded i.e. "7B+%22authenticationDTO%22%3A+%7B++++++%22merchantIdentifier%22%3A...." which is what causes the problem.

I tried the following with no success:
- replace double quotes with &quot, no other special characters for XML are found in the json;
- use jsonescape() as per CDATA docs - unsupported in Matillion;
- pass the json string as an input parameter;
- set the string with 'value' attribute of rsb:set;

I am aware I can do that using python, but it seems a fairly straightforward case for an API profile, so I would like to understand what is the right way to do it.

Thanks,
Danail

2 Community Answers

Matillion Agent  

Kalyan Arangam —

Hi Danali,

The driver may attempt to urlencode the POST body and found that adding a ContentType header helps.
Please check if adding the following line before the “URI” attribute helps.

<rsb:set attr="ContentType" value="application/json; charset=UTF-8" />

Best
Kalyan


Danail Georgiev —

It did the trick indeed.
Thanks a lot!

Post Your Community Answer

To add an answer please login