NetTalk Central

Author Topic: WebService json error response looks wrong  (Read 5610 times)

Simon Kemp

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
WebService json error response looks wrong
« on: December 08, 2016, 06:37:20 AM »
Hi,

I'm on 9.13 and working on a webservice. xml error response looks like this:-

<?xml version="1.0"  encoding="utf-8"?>
<GetSubscriberDetails_response xmlns="Subscriptions">
  <ServiceErrors>
    <Error>
      <ErrorNumber>9005</ErrorNumber>
      <ErrorPosition>GetSubscriberDetails</ErrorPosition>
      <ErrorRecordId>Password</ErrorRecordId>
      <ErrorDescription>Authentication Failed</ErrorDescription>
      <ErrorRecommendation/>
    </Error>
  </ServiceErrors>
</GetSubscriberDetails_response>

json like this :-

{
 "GetSubscriberDetails_response" : {
  "queue" : [
    {
     "ERRORNUMBER" : 9005,
     "ERRORPOSITION" : "GetSubscriberDetails",
     "ERRORRECORDID" : "Password",
     "ERRORDESCRIPTION" : "Authentication Failed",
     "ERRORRECOMMENDATION" : ""
    }
     ]
 }
}
 
What have I got wrong!? 

Thanks.


urayoan

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • AZ Rock Radio
Re: WebService json error response looks wrong
« Reply #1 on: December 08, 2016, 07:15:31 AM »
Simon, are you using an external tool to validate the json string?

In my case i use JSONLint. and at first it gave me errors about bad string in position 1 and the problem was the spaces after the {   (i think because the copy paste from the browser.

Simon Kemp

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: WebService json error response looks wrong
« Reply #2 on: December 08, 2016, 07:30:30 AM »
Hi,

I'm not really sure what you're asking, sorry!

I was driving at that "queue" when I expected "ServiceErrors", and "ERRORNUMBER" where I expected "ErrorNumber" ...

Thanks

urayoan

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • AZ Rock Radio
Re: WebService json error response looks wrong
« Reply #3 on: December 08, 2016, 10:30:23 AM »
Oh, i was thinking about the structure of the JSON  ;D


Simon Kemp

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: WebService json error response looks wrong
« Reply #4 on: December 09, 2016, 05:28:00 AM »
I think the main problem is this generated code:-

BuildResultFields  Routine
! Start of "Start of BuildResultFields Routine"
! [Priority 5000]

! End of "Start of BuildResultFields Routine"
  if p_web.RequestJSON
    If Records(p_web.ServiceErrorQueue)
      jsonResults.append(p_web.ServiceErrorQueue)


That last line should probably be :-

  jsonResults.append(p_web.ServiceErrorQueue, 'ServiceErrors')

And if I put this in the available embed :-

  json.SetTagCase(jf:CaseAsIs)

Things look better to me :-

{
 "GetSubscriberDetails_response" : {
  "queue" : [
   {
    "ErrorNumber" : 9005,
    "ErrorPosition" : "GetSubscriberDetails",
    "ErrorRecordId" : "Password",
    "ErrorDescription" : "Authentication Failed",
    "ErrorRecommendation" : ""
   }
  ]
 }
}

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: WebService json error response looks wrong
« Reply #5 on: December 12, 2016, 02:07:06 AM »
I agree Simon - I'll tweak that for the next build.

cheers
Bruce

Simon Kemp

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: WebService json error response looks wrong
« Reply #6 on: December 12, 2016, 02:30:50 AM »
Thank you sir.