Hey Rick,
I'm trying to make a request to the Stripe API to fetch a list of items.
The number of items returned can be restricted to value passed in the limit
parameter.
So I used...
oHTTP.AddPostKey("limit",lnLimit)
I get an error indicating that "limit" is an unknown parameter but I know that it is a valid parameter.
The request POST body shown in the Stripe request log shows this.
{
"limit": "50"
}
The limit parameter is being received as a string rather than as a number. So far, I have no definitive answer from Stripe if the data type is causing the error but in case this is the problem...
Is there a way to add a post key in such a way that the post body becomes this instead?
{
"limit": 50
}
BTW, I did try
lcJSON = [{ "limit": ] + TRANSFORM(lnLimit) + [ }]
oHTTP.AddPostKey("",lcJSON)
That gave me a parameter_missing
error and there was no request POST body shown in the request log.
Thanks, Carl
Values passed to AddPostKey()
have to be of type string
...
oHTTP.AddPostKey("limit",TRANSFORM(lnLimit))
But what you're posting here doesn't look like a HTTP form variables (which is what the above does), but rather a JSON document. You have to build the JSON string and then post that instead:
lcJson = "{ limit: " + TRANS(lnLimit) + " }"
Response.ContentType = "application/json"
oHttp.AddPostKey(lcJson)
Or if more complex use wwJsonSerializer to build up the JSON.
+++ Rick ---
Hi Rick,
I was barking up the wrong tree.
Because it's a REST API, the same URL is used for listing all items as for adding an item and "limit" is not a valid parameter for a POST operation.
Once I explicitly set the http verb to GET, it worked fine.
Sorry for the bother.
Thanks, Carl