NetTalk Central

Author Topic: API problem, NT 14.20  (Read 2918 times)

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
API problem, NT 14.20
« on: April 10, 2024, 12:18:47 PM »
Hi Bruce,

     I have an API set up.  An app in California is the client, sending data to a target tps file called Enrollment.tps on a remote server.  Numerous fields are loaded with data but one is not.  It is called BCS_Status.  In looking at the log in the Multi-site host (this app is a dll app) I do see the JSON, which shows the data is there.  See the attached image.  It shows:  "BCS_Status":"DRTBeforeSurgery", circled in blue.

     Using TPSSCAN I view the Enrollment table and see the BCS_Status field is blank.  All other fields contain data as expected.  I don't understand why this field is not assigned.  My API is set up with the Parameters tab with just the Enrollment table added.  The Returns tab just has two fields inserted.  I'm only allowing this API to do an Insert action.

     I can use Postman to send data to this API and all fields are filled in.

     Any thoughts as to why just one field is not filled when it does show in the JSON?

Thanks,

Jeff King
« Last Edit: April 10, 2024, 01:06:43 PM by jking »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: API problem, NT 14.20
« Reply #1 on: April 10, 2024, 09:49:04 PM »
I bet it's the only field in the table that uses an underscore?

What's happening is that the engine is seeing the BCS_ part as a prefix, and removing it.
The solution is either to work with that, or tell it to stop.

The easiest way to tell it to stop is to set the MaxPrefixLength property for the JSON object to be 1,2 or 3. It defaults to 4, (including the separator) which is why it's seeing this. You could also change the separator character (which is being set to _ as I recall).

Bruce

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: API problem, NT 14.20
« Reply #2 on: April 11, 2024, 08:44:43 AM »
Bruce,

     Could you explain how to do this and where?  I have tried numerous embeds.  Also, in the API, what is the name of the JSON object.  I'm not sure how to proceed here.

     Also, there are other fields in the table that use an underscore character, but they get assigned properly.  However, they all have more than 3 or 4 characters before the underscore character.  Is the problem here because BCS_Status has only three characters before the underscore?

Thanks,

Jeff
« Last Edit: April 11, 2024, 08:48:50 AM by jking »

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: API problem, NT 14.20
« Reply #3 on: April 11, 2024, 11:02:58 AM »
Bruce,

     After looking at the source, I have come up with this:  set  jsonParameter.SetMaxPrefixLength(1) in the Before Loading Parameter embed:

! Start of "Json Setup"
    ! [Priority 5000]
   
    ! End of "Json Setup"
    if json.LoadString(strjson) = jf:ok
      json.SetTagCase(jf:CaseAsIs)
      do FreeQueue:PatientEnrollment
      Clear(q:PatientEnrollment)
      jsonParameter &= json.GetByName('PatientEnrollment')
      if not jsonParameter &= Null
        jsonParameter.SetRemovePrefix(true)
        jsonParameter.SetMaxPrefixLength(Len('Enr') + 1)
        jsonParameter.SetPrefixChars('_')
        jsonParameter.SetTagCase(jf:CaseAsIs)
        jsonParameter.SetGroupName('PatientEnrollment')
        ! Start of "Before Loading Parameter"
        ! [Priority 5000]

            jsonParameter.SetMaxPrefixLength(1)     !my code here, set to either 1, 2 or 3
       
        ! End of "Before Loading Parameter"
        jsonParameter.Load(q:PatientEnrollment)
        ! Start of "After Loading Parameter"
        ! [Priority 5000]
       
        ! End of "After Loading Parameter"


Should this fix my prefix issue?

Thanks,

Jeff

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: API problem, NT 14.20
« Reply #4 on: April 15, 2024, 11:15:08 PM »
>> Should this fix my prefix issue?

yep.

>> Is the problem here because BCS_Status has only three characters before the underscore?

yep.