Subject Post JSon Data
From Robert Tin <robert@ricom.com.hk>
Date Sun, 19 Jan 2020 08:08:45 -0500
Newsgroups xb2net

If I use other tools to post JSon data to a server, it work OK and the related HTTP Request Header will show ..

POST /AIPersonCreate HTTP/1.1
User-Agent: Mozilla/4.0(compatible;MSIE6.0;Windows NT 5.0)
Connection: Keep-Alive
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 67

pass=12345678&person={"id":"p1","name":"test","idcardNum":"111111"}


If I use xb2.net to post JSon data and server return failed, the related HTTP header show ..

POST /AIPersonCreate HTTP/1.1
User-Agent: Xb2.NET/3.6.02.355
Accept: */*
Connection: Close
Cache-Control: no-cache
Host: 192.168.8.104:3000
Content-Type: application/x-www-form-urlencoded
Content-Length: 106

pass=12345678&person=%7B%22id%22%3A%22p2%22%2C%22name%22%3A%22test2%22%2C%22idcardnum%22%3A%22222222%22%7D


My code is following ..
  oForm := xbForm():new()
  oForm:SetVar("pass", "12345678")

  oJ := xbJSON():new()
  oJ:AddVar("id","p2")
  oJ:AddVar("name","test2t")
  oJ:AddVar("idcardnum","222222" )
  ? oJ:AsString()
  // it output  
  // {"id"="p2","name":"test2t","idcardNum":"222222"}

  oForm:SetVar( "person", oJ:AsString() )
  oResponse := oHttp:Execute("http://" + cServerIp + "/AIPersonCreate","POST",oForm )
  

Any suggestion ?

Thanks.


Recent messages in this thread
 
-# Post JSon Data (Current message) Robert Tin 19-Jan-2020 08:08 am
.\# Re: Post JSon Data Andreas Gehrs-Pahl 19-Jan-2020 04:46 pm