Specifying numeric values in HTTP Request JSON

(Perry Ismangil) #1

How do you specify numeric values when specifying the data in a HTTP Request action?

I can see in the log it always encloses the value in quotes, making it a string.

(Sarah Palombo) #2

You could strip out the quotes using our Text (string service) to remove the quotes?
If you’re not sure you could always send us your log for further inspection i’m sure we can give you a bit more guidance email that through is probably best (support@flowxo.com)

(John Jackson) #3

Actually it sounds like @ismangil is making a request here, rather than receiving. It would be best to send us more info from your log Perry so we can figure out what’s happening :+1:

(Perry Ismangil) #4

Yes, this is making a request.

The Task Model of Capsule API requires a few variables to be numeric.

I managed to make a JSON object matching the model except the numeric fields.

From the log, the object sent is:

{ "task": { "description": "This is a test task", "party": { "id": "57170385" }, "dueOn": "2017-01-30", " repeat": { "frequency ": "YEARLY", "interval ": "1", "on ": "1" } } }
This got an error response:

{"message":"Validation Failed","errors":[{"message":"invalid type for field","resource":"task","field":"party"}]}

Because the id field is not numeric as shown in the example:

{ "task" : { "description" : "Email product details", "party" : { "id" : 11587 }, "detail" : null, "dueOn" : "2014-05-20", "dueTime" : "18:00:48" } }

I want to specify that some fields in the request is numeric so no quotes in the JSON sent.

(John Jackson) #5

OK I think I understand what’s happening now. You’re building the JSON up using the key/value fields that you get when you choose JSON as the content type?

That won’t account for a numeric value.

Instead, choose ‘Raw Data’ and add a header named ‘Content-Type’ with the value ‘application/json’.

Then paste the JSON into the body field and you’ll be able to fix the ID so it’s a number instead of a string.

1 Like