Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
srp_com to post a http request
I need to post to a url passing a json string for the body.
I assume I can use srp_com to do this.
I've read through an earlier thread on this board. I've read through the associated blog and I've consumed the srp_com help but I'm still just guessing at how to go about it. I've used srp_com successfully before to get but never to post.
I'm trying to keep it simple to ensure I know what I'm doing but I could use some guidance please.
My code at this stage is like this
The 'send' appears to be doing something as it takes a moment to complete and I don't get any errors but I also don't get the result I'm looking for so I was hoping for some verification of my syntax before I go any further.
TIA
I assume I can use srp_com to do this.
I've read through an earlier thread on this board. I've read through the associated blog and I've consumed the srp_com help but I'm still just guessing at how to go about it. I've used srp_com successfully before to get but never to post.
I'm trying to keep it simple to ensure I know what I'm doing but I could use some guidance please.
My code at this stage is like this
If SRP_COM(objXmlHttp, "CREATE", "Msxml2.ServerXMLHTTP.6.0") then
TheError = SRP_COM(null$, "ERROR")
Status = oleStatus()
rv = SRP_COM(objXmlHttp, "Call", "open", "POST", theurl )
TheError = SRP_COM(null$, "ERROR")
rv = SRP_COM(objXmlHttp, "Call", "send", payload )
TheError = SRP_COM(null$, "ERROR")
Status = oleStatus()
Result = SRP_Com(objXmlHttp, "RELEASE")
end
The 'send' appears to be doing something as it takes a moment to complete and I don't get any errors but I also don't get the result I'm looking for so I was hoping for some verification of my syntax before I go any further.
TIA
Comments
Response = SRP_COM(objXMLHTTP, "GET", "responseBody") Responsetxt = SRP_COM(objXMLHTTP, "GET", "responseText") RespStat = SRP_COM(objXMLHTTP, "GET", "status") RespStatTxt = SRP_COM(objXMLHTTP, "GET", "statusText")
and there's an actual response telling me my body is empty so it looks like I'm on the right track.
'payload' wasn't empty though, so have I positioned that incorrectly or should I be looking elsewhere?
Let me rephrase that. I'll be looking elsewhere unless someone points out something I have missed.
"responseCode" and "responseStatus"
"setRequestHeader"
https://wiki.srpcs.com/display/HTTPFramework/HTTPClient_Services
Oh and I was too lazy to keep up with your HTTPFramework updates and forgot that the clientservices existed even though I had read about it some time ago.
I got a "just curious but why are you trying to use that method instead of this new one?" which sounded remarkably similar to So, with the switch to HTTPClient_services I also switched to the newer approach of the service I was after.
In truth I think their documentation of the legacy approach was not quite right but they've moved on and aren't going to fix it. I had received the same error when attempting via Postman so it wasn't the srp_com calls specifically.
No doubt though, the SendHTTPRequest service made it simpler to implement their new model.