+ Start a Discussion

Http Request, Authentication Errors

A small note I'll toss up here because I ran into it.  This is just informational.


The few lines of sample code for an HttpRequest call using a username/password was nice to have in the documentation.  It was just what I needed, and it was already done for me.  No thinking required.  :-)



Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'BASIC ' +
req.setHeader('Authorization', authorizationHeader);

 However, I was integrating with a service which has strictly implemented basic authentication and thus they deny the string "BASIC" and require the string "Basic" which is what I believe is in the Spec: http://tools.ietf.org/html/rfc2617.  Of course they didn't document that anywhere.


So, I post this just because if someone else had posted it I wouldn't have wasted an hour making sure every other darn thing was perfect before I figured this out.


Hope it helps someone, Steve.




Thanks Steve, i'll get the docs updated.

This was exactly what I needed when trying to consume a SOAP web service without using the WSDL generation tool. Thanks!