NetTalk Central

Author Topic: Passing Parameters to a Web Service  (Read 5109 times)

RichBowman

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Email
Passing Parameters to a Web Service
« on: May 03, 2018, 05:37:19 AM »
In my testing I've noticed that an & in the data stream can cause problems (when passing the parameter as a string to the url).

Are there other characters that should be off limits?

Also I'm having trouble understanding the "Clarion" way of calling this web service and passing it a JSON string with multiple records. Any sample code excerpts would be very welcome.
« Last Edit: May 03, 2018, 07:29:20 AM by RichBowman »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Passing Parameters to a Web Service
« Reply #1 on: May 03, 2018, 08:27:08 AM »
Hi Rich,

>> In my testing I've noticed that an & in the data stream can cause problems (when passing the parameter as a string to the url).
>> Are there other characters that should be off limits?

yes, there are a few. &, <, > " and '

There is a method
string = p_web._jsok(string)
that "sanitizes" the text. This is automatically called for browses and forms and so on, so if you are seeing it cause a problem then let me know where (specifically) the text is so I can check and see.

cheers
Bruce

RichBowman

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Email
Re: Passing Parameters to a Web Service
« Reply #2 on: May 03, 2018, 09:28:34 AM »
Just to be clear, we should avoid these in our data, so:

Bruce & Sons Lumber Co. should be Bruce and Sons Lumber Co.

Bruce's Cabinet Shop should be Bruces Cabinet Shop

Correct?

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Passing Parameters to a Web Service
« Reply #3 on: May 03, 2018, 04:33:36 PM »
Hi Rich,

You can't really avoid "Bruce & Sons Lumber Co." unless your users are fabulously well behaved.

But if you run your fields through p_web._jsok() it will fix them.

eg:

Bruce & Sons Lumber Co.

becomes

Bruce &amp; Sons Lumber Co.

NetTalk does this automatically pretty much all the time for you. But, there are times when you've got to do this yourself. Eg, if you are constructing a URL, then you must URL Encode the string.

Regards
Bill


RichBowman

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Email
Re: Passing Parameters to a Web Service
« Reply #4 on: May 04, 2018, 11:07:40 AM »
Clear explanation.

Thank you,