Page 1 of 1

Adding Headers Via JadeHttpConnection

Posted: Thu Jan 10, 2019 12:28 pm
by alanvl
Hi,

We are trying to build a Jade interface into Salesforce via REST. We are using the JadeHttpConnection. We have correctly logged in and are to the point of having received the authorization token but are having problems trying to add the authorization header to our subsequent http request.

We have defined an external method on JadeHttpConnection (based upon a hidden one that was already defined) ...
httpHeaderAdd(
type: Integer;
key: String;
index: Integer;
value: String) is "httpHeaderAdd" in "jadinet";

BUT it does not seem to actually update the header - I suspect we may not be assigning parameters correctly.

We have seen other posts which have suggested writing a .NET module to provide an interface but are not in a position to do this - we would like to be able to implement entirely in Jade. We are also aware of the SOAP API but have had issues with this and decided not to go any further with this.

Does anyone have any experience / suggestions that may help?

Re: Adding Headers Via JadeHttpConnection

Posted: Thu Jan 10, 2019 4:31 pm
by allistar
We have integrated to Salesforce before. My advice is to not use JadeHTTPConnection, it's lacking basic features. Instead use WinHttpRequest which is imported in the "Microsoft WinHTTP Services" activeX library.

Re: Adding Headers Via JadeHttpConnection

Posted: Fri Jan 11, 2019 8:01 am
by alanvl
Thanks Allistar, we are trying this at the moment but are having problems with a -2147012890 error on the call to the open - you wouldn't by chance have some sample code?

Ta Alan v.L

Re: Adding Headers Via JadeHttpConnection

Posted: Fri Jan 11, 2019 8:09 am
by allistar

Code: Select all

vars vRequest: WinHttpRequest; vResponse: String; vData: String; begin create vRequest transient; vRequest.open("POST", aInstanceEndpoint & URL, false); vRequest.setRequestHeader("Authorization", "Bearer " & aAccessToken); //this forces the component to negotiate the SSL protocol instead of using the default //https://docs.microsoft.com/en-us/windows/desktop/winhttp/winhttprequestoption pRequest.putOption(9, 0); vData := '{<JSON DATA HERE>}'; vRequest.send(vData); vResponse := vRequest.responseBody().StringUtf8.String; //process errors etc epilog delete vRequest; end;