I have set up an API POST call in Postman and it works fine.
When I try do recreate this in Alteryx with the Download tool I get this message:
HTTP/1.1 400 Bad Request
{"Message":"The request is invalid.","ModelState":{"authenticationInfo":["Unexpected character encountered while parsing value: a. Path '', line 0, position 0."]}}
It seems like the URL and headers are fine. The problem is the Payload where it takes in a JSON string (authenticationInfo) with username and password.
I've tried using every option in the Payload settings, including reading the JSON from Text input and as plain JSON in "Query String/Body".
When I google the error message most posts says the JSON string is not deserialized correctly. Is this an error with the Download tool?
Here's the JSON:
{ "UserName": "string 1", "UserPassword": "string 2" }
[EDIT]
I tried calling the API with the Python tool and got the same error.
Solved! Go to Solution.
Hi @jeneir , did you try passing the username and password in the compose query strings as highlighted below?
or try passing along with the url by creating separate fields and use those fields in one of the options.
Also, you can try passing the creds in the connection tab as well.
Thanks.
Hi! I tried to add UserName and Password to Compose..., but that just gave me a time-out.
Then tried to pass authenticationInfo as a JSON but that gave the same error as before.
authenticationInfo {"UserName": "username","UserPassword": "password"}
Is it possible to view the raw data Alteryx send? Maybe the Download tool uses an american apostrophe to enclose the string or something?
[EDIT] Tried Conncetion tab also, gave a time-out.
Let's start by asking the simple questions first, I don't think it will be a problem with the download tool itself as otherwise I'd expect many people would have bumped into a similar issue.
Firstly, have you definitely set-up the download tool to make a post request?
If you are sending the API request as JSON, have you created a 'Content-Type' header which is given as application/json?
Personally, I would place the json in a formula tool with the name 'authenticationInfo' and use the following formula...
'{"UserName":"username","UserPassword":"password"}'
And then check use this configuration...
If you can share screenshots of you config in postman vs. Alteryx then that will help further of course, alongside details of the API, is it one that others can easily subscribe too to test?
Ben
Thanks for reply.
I tried adding the formula tool but didn't help.
Postman:
Alteryx:
I tried with just application/json too but was no difference.
API doc: https://www.altinn.no/api/Help/Api/POST-authentication-authenticatewithpassword
Still getting the error...
{"Message":"The request is invalid.","ModelState":{"authenticationInfo":["Unexpected character encountered while parsing value: a. Path '', line 0, position 0."]}}
@jeneir can you change the payload tab to that specified by the post I gave, i.e. by using the 'take query string/body from field' option and selecting your field there.
I believe this may then resolve your issue.
Ben
tried all ways possible.
field from formula tool
I'd consider reaching out to Alteryx Support whom will be able to help you more pro-actively (i.e. on a call, rather than a load of back and forth on here).
Sorry I can't be of more help, but I've got you too a different error message at least! 😂
Ben