cpjamloki
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2015
06:59 AM
Getting HTTP response code 400
I have to post http request to server,but i have json data as a parameter like:
So for
So i have made above parameter as string using chr(34). (is it good idea or there is any function for it?)
and it converted as string . then my url.AsyncPostFromString(param) post http request fine.
Even i got msg.GetInt() = 1 means transfer complete.
But i am getting response code from server as 400. (if i am taking
if i am not taking AddHeader then response code coming 415.
i think problem is : parmeter converted in string format using chr(34). is there is any function for it?
help me to solve this issue.
{"abcdefgh":{"isD":false,"soapRequest":{"contractAcceptanceMedium":"WEB"}},"searchCustomerProfileRestRequest":{"soapRequest":{"cSearch":{"address":{"streetAddress1":"NTAwIEUgRnJhbmtsaW4gU3Q=","unitNumber":"NzY0Mg==","zipCode":"MjMyMTk="},"sessionId":""}}},"selectCustomerProfileRestRequest":{"soapRequest":{"sessionId":"","searchSelectionChoice":{}}},"queryBadt":{"soapRequest":}
So for
url.AsyncPostFromString(parameter)i have to pass parameter as string.
So i have made above parameter as string using chr(34). (is it good idea or there is any function for it?)
and it converted as string . then my url.AsyncPostFromString(param) post http request fine.
Even i got msg.GetInt() = 1 means transfer complete.
But i am getting response code from server as 400. (if i am taking
url.AddHeader("Content-Type","application/json")
if i am not taking AddHeader then response code coming 415.
i think problem is : parmeter converted in string format using chr(34). is there is any function for it?
help me to solve this issue.
14 REPLIES 14

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2015
07:38 AM
Re: Getting HTTP response code 400
Chr(34) is a quote character. I'm not sure what you mean when you say you changed a string into a string using Chr(34). To pass any string as a URL parameter you should encode it using roUrlTransfer.Escape() or something similar.
--Mark
--Mark
cpjamloki
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2015
11:15 PM
Re: Getting HTTP response code 400
Thanks markn for reply. Actually i have parameter like:
i have to send it as a http post request.
If i paas parameter here:
it gives me syntax error , b/c parameter should be in string form. So i am not understanding how to pass param here.
param = {"abcd":{"isDevice":false,"soapRequest":{"cMedium":"WEB"}},"searchCustomerProfileRestRequest":{"soapRequest":{"customerSearch":{"address":{"streetAddress1":"NT=","unitNumber":"NzY0Mg==","zipCode":"MyMTk="},"sessionId":""}}},"ProfileRestRequest":{"soapRequest":{"sessionId":"","searchSelectionChoice":{}}},"queryBadDebtRestRequest":{"soapRequest":{"sessionId":"","firstName":null,"lastName":null,"emailAddress":null,"socialSecurityNumber":null,"telephoneNumber":null,"creditCheckConsent":false},"dateOfBirth":null}}
i have to send it as a http post request.
If i paas parameter here:
url.AsyncPostFromString(param)
it gives me syntax error , b/c parameter should be in string form. So i am not understanding how to pass param here.

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015
07:43 AM
Re: Getting HTTP response code 400
Oh when you said it was JSON data I thought you meant you had already converted it to a JSON string. This was already discussed in your other thread: viewtopic.php?f=34&t=89668. You should use FormatJSON to convert the AA to a string, and then roUrlTransfer.Escape to escape the metacharacters so that it can be passed in a URL. Note however that the server must be set up to expect the data in JSON format. If it's expecting some other format then you need to convert to that format rather than JSON.
--Mark
--Mark
cpjamloki
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015
07:58 AM
Re: Getting HTTP response code 400
Markn,
If i use
If i use
FormatJson(param)here. It gives me syntax error.

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015
08:36 AM
Re: Getting HTTP response code 400
Can you post a complete function that exhibits the problem and the exact error message? I don't see any way that the line you posted can produce a syntax error message.
--Mark
--Mark


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015
10:51 AM
Re: Getting HTTP response code 400
"cpjamloki" wrote:
I have to post http request to server,but i have json data as a parameter like:
...
You can either start with a valid JSON value in a string, that you got from a server or built yourself, or you can start with an object representation, i.e. an associative array.
If you are starting with a JSON string value, but you want to change some values or otherwise manipulate it, you can first convert it to an object representation using ParseJSON.
Then, when the object representation is the way you want, you can convert it to a JSON string value using FormatJSON.
You should sent that string value as the parameter to your AsyncPostFromString call.
(I doubt you want to do any escaping at that point, as the POST is sending data, not a URL).
Example:
s = "{'a':'z','b':2}"
s = s.Replace("'", chr(34))
print s
REM {"a":"z","b":2}
o = ParseJSON(s)
o.b = 3
s = FormatJSON(o)
print s
REM {"a":"z","b":3}
cpjamloki
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2015
01:50 AM
is Roku support to post json data
Actually i want to know :
is Roku support to post json data? I need same as:-
viewtopic.php?f=34&t=64647&sid=988df4e8559d24ee1b525b7f17590cc82
is Roku support to post json data? I need same as:-
viewtopic.php?f=34&t=64647&sid=988df4e8559d24ee1b525b7f17590cc82
cpjamloki
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2015
01:40 PM
Re: Getting HTTP response code 400
please Roku confirm that: is Roku support to post json data?


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2015
05:00 PM
Re: Getting HTTP response code 400
"cpjamloki" wrote:
please Roku confirm that: is Roku support to post json data?
Sure, you can post JSON data. 🙂 From your initial post here, you already know how to POST using AsyncPostFromString.
If you are setting the Content-Type header appropriately, as you indicated, and have verified that the string you are posting is valid JSON, then perhaps you need to diagnose from the service that you are sending to that the data contents conform to the protocol it expects.