cancel
Showing results for 
Search instead for 
Did you mean: 

using formulas in HTTP Post body

dstein61
Deputy Chef I
Deputy Chef I

Hi, I'm trying to build my first HTTP connector recipe and I'm running into an issue when I try to use formulas in the request body of a Post call. The request content type is set to json and everything works fine when the body is set to "text". I can add data pills to dynamically set json content and the Post call succeeds and receives the expected response. 

I'd like to use formulas to format some of the data pill content (like .downcase).  However, as soon as I switch the Request body window from "text" to "formula", the recipe fails with a 415 error (Unsupported Media Type). At this point, I haven't used any formulas, I've only switched the Request body from "text" to "formula". 

In comparing the input json that works (screenshot 1) to the json that fails (screenshot 2), I noticed that the body of json sent as "text" is surrounded by quotation marks, while the body sent as "formula" is not. This doesn't seem to be anything that I can control.

succeeds.png fails.png

Has anyone come across this before? Thanks.

1 ACCEPTED SOLUTION

gary1
Executive Chef II
Executive Chef II

Can you send a screenshot of the input/body on the HTTP action? I'd like to see how your formula is written.

Edit: I remember running into this a while ago. I found the simplest way around it was to store the data transformations in a variable before the HTTP, and then insert the variable data pills directly into the text payload. This avoids having to clutter your payload with a lot of inline transformation and ultimately avoids this problem entirely : )

That said, I'm still curious to figure out the root of the issue!

View solution in original post

3 REPLIES 3

gary1
Executive Chef II
Executive Chef II

Can you send a screenshot of the input/body on the HTTP action? I'd like to see how your formula is written.

Edit: I remember running into this a while ago. I found the simplest way around it was to store the data transformations in a variable before the HTTP, and then insert the variable data pills directly into the text payload. This avoids having to clutter your payload with a lot of inline transformation and ultimately avoids this problem entirely : )

That said, I'm still curious to figure out the root of the issue!

Hi @gary1, thanks for the reply. What your saying about storing the data transformations in variables makes sense. I'll give that a shot.

Here's screenshot of my formulas. This show all the formulas that I'd like to use, but I still get the 415 error even when "name" is the only field with a formula and the rest are replaced with hardcoded values. I agree that it would be great to get to the root of the issue!

formulas.png

mppowe
Executive Chef I
Executive Chef I

In formula mode you have to quote your text.  In your example, I think you'd have to wrap the whole thing in single-quotes, either that or use double-quotes but then use single-quotes for the key-value pairs.  I think you'd also have to close the text and add the variables outside the text, like in programming.  That's where I think it gets really confusing/ugly, and which is why I (like Gary) tend to do that stuff outside of the body.  For example, I think it would look something like...

"{ 'name':'" + <FullName-DataPill>.titleize + ",

'login':'" + <FirstName-DataPill>.downcase + "." + <LastName-DataPill>.downcase + ",  ....

etc etc.  You could play with it using just one field at a time to see if you got the syntax right.  But troubleshooting is certainly easier using variables beforehand.  BUT, it's more Tasks!  So then there's that.