Forum Discussion

cpjamloki's avatar
cpjamloki
Visitor
10 years ago

Getting HTTP response code 400

I have to post http request to server,but i have json data as a parameter like:
{"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

  • Since you won't post the code and the error message as I previously asked, we can only guess, but it seems that you are passing an AssociativeArray to AsyncPostFromString. It needs to be a string, not an AA, as you yourself said in your last post. An AA is not a string. This code should work. Note that the first line is necessary since "null" is not a reserved word in Brightscript, as RokuKC already told you earlier.


    null = invalid

    param={"abcd":{"isDevice":false,"soapRequest":{"contractAcceptanceMedium":"WEB"}},"searchCustomerProfileRestRequest":{"soapRequest":{"customerSearch":{"address":{"streetAddress1":"UgRnJhbmtsaW4gU3Q=","unitNumber":"NzY0Mg==","zipCode":"MjMyMTk="},"sessionId":""}}},"selectCustomerProfileRestRequest":{"soapRequest":{"sessionId":"","searchSelectionChoice":{}}},"queryBadDebtRestRequest":{"soapRequest":{"sessionId":"","firstName":null,"lastName":null,"emailAddress":null,"socialSecurityNumber":null,"telephoneNumber":null,"creditCheckConsent":false},"dateOfBirth":null}}

    param_string = FormatJSON(param)

    url.AsyncPostFromString(param_string)


    If you are still having problems, please POST THE ERROR MESSAGE that you are seeing.

    --Mark
  • Hi Mark,
    i have send you private message regarding this on forum, please find it. here you can see :
    Error generating by debug console:

    *** ERROR compiling /pkg:/source/services.brs:
    Syntax Error. (compile error &h02) in pkg:/source/services.brs(14)


    Thanks
  • RokuMarkn, doesn't that AA syntax require the 7.x firmware? I suspect that's the source of cpjamloki's syntax error.