NetTalk Central

Author Topic: webservices and json  (Read 3704 times)

Andjane

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
webservices and json
« on: December 13, 2016, 02:18:57 AM »
something weird with the content type.

I looked at the webinair API (3) example and used the current client.app example to test posting json payloads to my server.

net.customheader = '' 
net.ContentType = net.GetContentType('.jason')   ! <<==============
json.start()
collection &= json.CreateCollection('payload')
collection.append(AuthenticationGroup,'authentication')
collection.append(RegisterUserGroup,'registrations')
json.SaveString(str,true)
net.Put(clip(Server) & '/uneeqo/receivenewuser/',str.Getvalue())

In the above Line  ! <<==============

when i use this format of content type  the request on the client side is json but the server does not show any retrieved information in my debug lines.
If i replace that line with net.ContentType = 'application/json' . I can see the data in the debug lines.

This in it self id not a problem. but the response  the client receives is text/xml But i need it in json format.

In the server method generated code is see the following which also sets the content type GetContentType('.json') .
either i am missing something or i am not initializing the content type

 p_web.ReplyContentFixed = 1
  if p_web.RequestJSON
    p_web.ReplyContentType = p_web._GetContentType('.json')
    jsonResults &= json.CreateCollection('Response')
    do BuildResultFields
    json.SaveString(packet,true)


thanks

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: webservices and json
« Reply #1 on: December 15, 2016, 03:26:18 AM »
net.ContentType = net.GetContentType('.jason') 

should be

net.ContentType = net.GetContentType('.json') 

Cheers
Bruce