Adding Headers Via JadeHttpConnection

Forums for specific tips, techniques and example code
alanvl
Posts: 29
Joined: Fri Aug 14, 2009 9:16 pm

Adding Headers Via JadeHttpConnection

Postby alanvl » Thu Jan 10, 2019 12:28 pm

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?

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

Re: Adding Headers Via JadeHttpConnection

Postby allistar » Thu Jan 10, 2019 4:31 pm

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.

alanvl
Posts: 29
Joined: Fri Aug 14, 2009 9:16 pm

Re: Adding Headers Via JadeHttpConnection

Postby alanvl » Fri Jan 11, 2019 8:01 am

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

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

Re: Adding Headers Via JadeHttpConnection

Postby allistar » Fri Jan 11, 2019 8:09 am

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;


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 19 guests