Forum Discussion
Hi Dragan,
Thank you for your reply. I have implemented the encodeURIComponent call as you describe but I am getting the same 400 error. Please see the exact line below…
“grant_type=”+encodeURIComponent(“password”)+“&username=”+encodeURIComponent(account.username)+“&password=”+encodeURIComponent(account.password)
I have the Upload body type fields set to “Multipart form-data”. Does this need to be changed, or is there another setting on this snap that may need to be adjusted?
Thanks,
James
encodeURIComponent(“password”) is just password (there’s nothing that needs to be encoded), so you could simplify that to just "grant_type=password&username=" + ...
But I still don’t understand how you’re able to get account.username and account.password to resolve.
Upload body type isn’t used here. But you do need to add a row to the “HTTP header” table with Content-Type application/x-www-form-urlencoded, as I showed in the screenshot from my last reply.
- ptaylor4 years agoEmployee
Ah! I just looked at that other Community post you linked. I wasn’t aware of that hack. But I’m pretty sure it only works in an expression used in the Value column of the HTTP Headers table, not anywhere else. I don’t think you’ll be able to use it for the request body.
- jsmith1414 years agoNew Contributor III
Oh I apologize for the confusion, I already had that specific header in place We are successfully using the account.username and account.password in another pipeline i.e. in the HTTP entity field of the POST snap.
- ptaylor4 years agoEmployee
Wow! You’re right. I guess I hadn’t tried it with exactly the right syntax. This expression works just fine in the HTTP Entity field:
"grant_type=password&username=" + account.username +"&password=" + encodeURIComponent(account.password)