NetTalk Central

Author Topic: Calling webservice methods json vs xml  (Read 4072 times)

MikeR

  • Sr. Member
  • ****
  • Posts: 265
    • View Profile
    • Email
Calling webservice methods json vs xml
« on: May 25, 2020, 04:42:58 AM »
when I do a xml post my api works
when I do a json post I get errors

the following inputs and outputs:
1 xml
Input
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <apiRegister xmlns="">
      <ClientIn>
        <USERID>**value**</USERID>
        <PASSWORD>**value**</PASSWORD>
        <CLIENTGUID>**value**</CLIENTGUID>
        <MANUALCODE>**value**</MANUALCODE>
        <TITLE>**value**</TITLE>
        <INITIALS>**value**</INITIALS>
        <FIRSTNAMES>**value**</FIRSTNAMES>
        <SURNAME>**value**</SURNAME>
        <IDNUMBER>**value**</IDNUMBER>
        <IISVALIDSA>**value**</IISVALIDSA>
        <CELLPHONE>**value**</CELLPHONE>
        <EMAIL>**value**</EMAIL>
        <HOMETEL>**value**</HOMETEL>
        <WORKTEL>**value**</WORKTEL>
        <FAXNO>**value**</FAXNO>
        <POSTALADDRESS>**value**</POSTALADDRESS>
        <RESIDENTIALADDRESS>**value**</RESIDENTIALADDRESS>
        <LANGUAGE>**value**</LANGUAGE>
        <DATEOFBIRTH>**value**</DATEOFBIRTH>
        <SEX>**value**</SEX>
        <CELLPHONEVERIFIED>**value**</CELLPHONEVERIFIED>
        <EMAILVERIFIED>**value**</EMAILVERIFIED>
        <OCCUPATION>**value**</OCCUPATION>
        <PASSPORTNUMBER>**value**</PASSPORTNUMBER>
        <BROKERGUID>**value**</BROKERGUID>
        <CHANGEDBY>**value**</CHANGEDBY>
      </ClientIn>

    </apiRegister>
  </soap:Body>
</soap:Envelope>

OutPut:
<?xml version="1.0"  encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <apiRegister_response xmlns="">
      <ServiceErrors>
        <Error>
          <ErrorNumber>2</ErrorNumber>
          <ErrorPosition>apiClient</ErrorPosition>
          <ErrorRecordId>CLI_CLIENTGUID=**value**</ErrorRecordId>
          <ErrorDescription>Invalid Title; **value**</ErrorDescription>
          <ErrorRecommendation/>
        </Error>
        <Error>
          <ErrorNumber>4</ErrorNumber>
          <ErrorPosition>apiClient</ErrorPosition>
          <ErrorRecordId>CLI_CLIENTGUID=**value**</ErrorRecordId>
          <ErrorDescription>Invalid IdNumber: **value**</ErrorDescription>
          <ErrorRecommendation>SA ID Number must be a 13 digit numeric number</ErrorRecommendation>
        </Error>
        <Error>
          <ErrorNumber>8</ErrorNumber>
          <ErrorPosition>apiClient</ErrorPosition>
          <ErrorRecordId>CLI_CLIENTGUID=**value**</ErrorRecordId>
          <ErrorDescription>Invalid Language: **value**</ErrorDescription>
          <ErrorRecommendation/>
        </Error>
        <Error>
          <ErrorNumber>9</ErrorNumber>
          <ErrorPosition>apiClient</ErrorPosition>
          <ErrorRecordId>CLI_CLIENTGUID=**value**</ErrorRecordId>
          <ErrorDescription>Invalid Sex: **value**</ErrorDescription>
          <ErrorRecommendation>Must be Male or Female</ErrorRecommendation>
        </Error>
        <Error>
          <ErrorNumber>10</ErrorNumber>
          <ErrorPosition>apiClient</ErrorPosition>
          <ErrorRecordId>CLI_CLIENTGUID=**value**</ErrorRecordId>
          <ErrorDescription>Client with ID:**value** already Exists</ErrorDescription>
          <ErrorRecommendation/>
        </Error>
      </ServiceErrors>
    </apiRegister_response>
  </soap:Body>
</soap:Envelope>

This is an expected result
However
when I input Json

{
  "ClientIn" : {
    "USERID" : value,
    "PASSWORD" : value,
    "CLIENTGUID" : value,
    "MANUALCODE" : value,
    "TITLE" : value,
    "INITIALS" : value,
    "FIRSTNAMES" : value,
    "SURNAME" : value,
    "IDNUMBER" : value,
    "IISVALIDSA" : value,
    "CELLPHONE" : value,
    "EMAIL" : value,
    "HOMETEL" : value,
    "WORKTEL" : value,
    "FAXNO" : value,
    "POSTALADDRESS" : value,
    "RESIDENTIALADDRESS" : value,
    "LANGUAGE" : value,
    "DATEOFBIRTH" : value,
    "SEX" : value,
    "CELLPHONEVERIFIED" : value,
    "EMAILVERIFIED" : value,
    "OCCUPATION" : value,
    "PASSPORTNUMBER" : value,
    "BROKERGUID" : value,
    "CHANGEDBY" : value
  }
}

I get:

{
   "apiRegister_response" : {
      "ServiceErrors" : [
         {
            "ERRORNUMBER" : 9007,
            "ERRORPOSITION" : "apiRegister",
            "ERRORRECORDID" : "Input:Record",
            "ERRORDESCRIPTION" : "JSONClass.HandleChar: Unexpected literal (v) at position: 35 USERID\" : value,\n    \"PASSWORD\" : value,\n    \"CLIENTGUI",
            "ERRORRECOMMENDATION" : "Review JSON data and correct it."
         }
      ]
   }
}


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Calling webservice methods json vs xml
« Reply #1 on: May 25, 2020, 11:20:56 PM »
In JSON value
is not a number.

so
"USERID" : value,
is not legal JSON.
it needs tobe
"USERID" : "value",
or
"USERID" : 123,

Cheers
Bruce

MikeR

  • Sr. Member
  • ****
  • Posts: 265
    • View Profile
    • Email
Re: Calling webservice methods json vs xml
« Reply #2 on: May 26, 2020, 04:28:10 AM »
Thanks Bruce ,
How do I get the deaults to show as "value" instead of value in the test api screen ?

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Calling webservice methods json vs xml
« Reply #3 on: May 26, 2020, 09:44:03 PM »
better yet, put something into the value....