Web Connection
Posting JSON Data using httpget
Gravatar is a globally recognized avatar based on your email address. Posting JSON Data using httpget
  Pinaki Mukherjee
  All
  Dec 28, 2020 @ 09:02pm

I need to post JSON Data into a url. Somehow, not working for me with the following code:

Ohttp=NEWOBJECT("WWhTTP","\SHCOMMON\WCONNECT\CLASSES\WWHTTP.PRG")			
oHTTP.AddHeader("Authorization",m.cUtrade_Authorisation)
oHttp.cContentType = "application/json" 
* Now set the JSON
oHttp.AddPostKey(m.cJson) 
* Now hit the server
oHttp.httpGet(m.cUtrade_Url)

Any help will be appreciated -- Pinaki

Gravatar is a globally recognized avatar based on your email address. re: Posting JSON Data using httpget
  Rick Strahl
  Pinaki Mukherjee
  Dec 28, 2020 @ 09:29pm

Not helpful when all you provide - is It's not working.

  • Error codes if any?
  • What is the server response if any?
  • Response headers?
Gravatar is a globally recognized avatar based on your email address. re: Posting JSON Data using httpget
  Pinaki Mukherjee
  Pinaki Mukherjee
  Dec 28, 2020 @ 10:13pm

The oHttp.nError is "12037" and oHttp.cErrorMsg is "The date in the certificate is invalid or has expired"

can I ignore the ssl certificate error?

++ Pinaki

Gravatar is a globally recognized avatar based on your email address. re: Posting JSON Data using httpget
  Rick Strahl
  Pinaki Mukherjee
  Dec 29, 2020 @ 01:13pm

This sounds like an expired server certificate which means the certificate is basically invalid.

Yes you can ignore the certificate error, but it's really not recommended!

#include wconnect.h  && to get the flag constant

loHttp = CREATEOBJECT("wwHttp")
loHttp.nHttpServiceFlags = INTERNET_FLAG_IGNORE_CERT_DATE_INVALID

There are a number of other Certificate ignore flags in wconnect.h.

None of this is recommended. If the cert is expired or invalid it isn't secure and defeats the purpose of using TLS in the first place.

+++ Rick ---

© 1996-2021