Hi All
I am working with an api for a accounting package - I can extract information from the accounting package
if oHttp:open()
cItems2 := oHttp:ReadAll()
MEMOWRIT( "MYRESULT1.TXT", cItems2)
this is what the text file shows
{
"UID": "17ef4d73-cfa7-43fb-afe6-5350cbffffa9",
"CompanyName": "Techdata Software",
"IsIndividual": false,
"DisplayID": "TEC01",
"IsActive": true,
"Addresses": [
{
"Location": 1,
"Street": "32 Pingrup Lane\r\nScarborough ",
"City": null,
"State": "WA",
"PostCode": "6019",
"Country": null,
"Phone1": "08 9245 8945",
"Phone2": null,
"Phone3": null,
"Fax": null,
"Email": null,
"Website": null,
"ContactName": "Colin Haig",
"Salutation": "Mr"
}
],
}
I can then get the companyname
hb_jsondecode(cItems2,@hJson)
MsgInfo(hJson["CompanyName"]) displays "TechData Software"
I need to modify the companyname or change the contact name and then be able to post back
oHttp:Post(hJson,cUri)
Regards
Colin
json
- Daniel Garcia-Gil
- Posts: 2365
- Joined: Wed Nov 02, 2005 11:46 pm
- Location: Isla de Margarita
- Contact:
Re: json
Hello
you can use hJson
hb_jsondecode(cItems2,@hJson)
hJson["CompanyName"] = "My New Company Name"
cJson = hb_JsonEncode(hJson)
oHttp:hFields["Content-Type"] = "application/json"
now you can post
oHttp:Post(hJson,cUri)
you can use hJson
hb_jsondecode(cItems2,@hJson)
hJson["CompanyName"] = "My New Company Name"
cJson = hb_JsonEncode(hJson)
oHttp:hFields["Content-Type"] = "application/json"
now you can post
oHttp:Post(hJson,cUri)
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
-
- Posts: 310
- Joined: Mon Oct 10, 2005 5:10 am
Re: json
Hi Daniel
cJson = hb_JsonEncode(hJson)
What should the valtype of cJson be. ?
oHttp:hFields["Content-Type"] = "application/json"
now you can post
I presume cJson shoud be passed to the post method not hJson
oHttp:Post(hJson,cUri)
I am still having issues with the update
METHOD PostByVerb( xPostData, cQuery, cVerb ) CLASS TIPClientHTTP
IF ::inetErrorCode( ::SocketCon ) == 0
MsgInfo('here')
::inetSendAll( ::SocketCon, cData )
::bInitialized := .T.
RETURN ::ReadHeaders()
else
MsgInfo(::inetErrorCode( ::SocketCon ))
ENDIF
::ReadHeaders() - always return .f.
METHOD ReadHeaders( lClear ) CLASS TIPClientHTTP
cLine := ::inetRecvLine( ::SocketCon, @nPos, 500 )
cLine is always empty
IF Empty( cLine )
// In case of timeout or error on receiving
RETURN .F.
ENDIF
Thanks for your suggestion.
Regards
Colin
cJson = hb_JsonEncode(hJson)
What should the valtype of cJson be. ?
oHttp:hFields["Content-Type"] = "application/json"
now you can post
I presume cJson shoud be passed to the post method not hJson
oHttp:Post(hJson,cUri)
I am still having issues with the update
METHOD PostByVerb( xPostData, cQuery, cVerb ) CLASS TIPClientHTTP
IF ::inetErrorCode( ::SocketCon ) == 0
MsgInfo('here')
::inetSendAll( ::SocketCon, cData )
::bInitialized := .T.
RETURN ::ReadHeaders()
else
MsgInfo(::inetErrorCode( ::SocketCon ))
ENDIF
::ReadHeaders() - always return .f.
METHOD ReadHeaders( lClear ) CLASS TIPClientHTTP
cLine := ::inetRecvLine( ::SocketCon, @nPos, 500 )
cLine is always empty
IF Empty( cLine )
// In case of timeout or error on receiving
RETURN .F.
ENDIF
Thanks for your suggestion.
Regards
Colin
- Daniel Garcia-Gil
- Posts: 2365
- Joined: Wed Nov 02, 2005 11:46 pm
- Location: Isla de Margarita
- Contact:
Re: json
yes right, sorry my mistakeColin Haig wrote: I presume cJson shoud be passed to the post method not hJson
Colin
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9