Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

API call works in Postman but not in Alteryx "Body of request expected to be JSON"

AkisM
10 - Fireball

Trying to use the download tool in Alteryx for the first time, but running into some issues. Namely, the API call returns the following error:

 

"The body of the request, which was expected to be JSON, was invalid, and could not be decoded. The start of an object { or an array [ was expected."

 

The weird thing is that the call works fine on postman with the same configuration.

 

Attaching below postman and workflow screenshots.

 

Post=postman headers, cap2=postman payload

Headers=alteryx headers, payload=alteryx payload

 

Any ideas?

 

5 REPLIES 5
BrandonB
Alteryx
Alteryx
This is a helpful article to get started with API calls. https://community.alteryx.com/t5/Alteryx-Knowledge-Base/APIs-in-Alteryx-cURL-and-Download-Tool/ta-p/...

I think you are close but I can’t see what the body looks like in the payload tab of the download tool. Did you paste in the JSON body that you have in Postman? Specifically from your post.PNG picture.
cadyb
Alteryx
Alteryx

I recently had some trouble using the payload as a field. I ended up using a batch macro to update the update the payload in the call instead and it started working fine! Same situation - request was working fine in Postman. You might want to give that a try!

 

Cady

AkisM
10 - Fireball

Hi @BrandonB ,

 

Thanks for the link, I already went through the article. It was helpful but couldn't solve my issue. Also, I didn't paste in the body that is seen in the post.PNG picture. That was what was returned by the server after sending the API call.

 

Basically for the service I'm trying to use, you send a post call to get an authentication key (which I did and works fine), then you send another post call to get a subscriptionId (kind of like a second key), as seen in post.PNG. However the second post call I'm trying returns the JSON format error described above.

 

@cadyb Unfortunately I have no idea how to use batch macros or how they can work together with the download tool. Can you elaborate?

AkisM
10 - Fireball

I think I narrowed down the issue to my payload being wrong. From what I read in this specific API's documentation, the following is needed:

 

{"accounts":{"transactionHistory":"true","balance":"true","details":"true,"checkFundsAvailability":"true"}, "payments":{"limit":100.00,"currency":"LSL","amount":18.32101}}

 

I'm not a programmer, but reading articles on the alteryx download tool I know "accounts" and "payments" are supposed to be the names of 2 of the objects in the "query string/body" section of payload in the download tool, and their values should be the multiple values listed in their respective tables/arrays (whatever they're called).

 

My problem is, I thought that alteryx can only receive 1 name, 1 value at a time. How do I configure the tool to have 1 payload name with multiple values as shown above? Or do I have to list "accounts" as name 4 times and give it 4 different values for example? Even so, how would the syntax look like in the download tool? It seems each time I have 2 names and 1 value. i.e. Accounts>TransactionHistory: true, Accounts>Balance:true, Payments>Limit: 100, Payments>Currency: LSL. Download tool only gives 1 cell for name and 1 cell for value.

 

EDIT: I buypassed the query editor that the download tool comes with and just selected "take body from Field", and copy pasted the array in the field. It works now.

BrandonB
Alteryx
Alteryx
Glad you got that figured out! I normally use the name/value boxes for the simple API queries and paste the JSON when there is a lot going on or multiple layers in the JSON. You can also feed in other fields from upstream in your workflow which can make the API call dynamic by switching out one of the payload values depending on what happens before.
Labels