+ Start a Discussion

Basic Authentication - httprequest



I was wondering if we could use something different then basic authentication.


If i do a post to an url using C# with this example


String usern = "test"; String passw = "test"; myReq.Credentials = new NetworkCredential(usern, passw); myReq.PreAuthenticate = true; myReq.Method = "POST";

 then the post works fine.


If i use the same url but do the authentication using the examples found in the docs then i get an access denied.


Apex code



String username = 'test'; String password = 'test'; Blob headerValue = Blob.valueOf(username+':'+password); String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization', authorizationHeader);


 So i think the server does not use Basic authentication (i don't have access to the server).


What is the difference between the 2 methods and can i do authentication like the C# example in Salesforce?


Thanks for your help



Did you ever resolve this issue?



Were you able to resolve this issue?


No not really,


i resolved it by asking the client to set his webserver to allow basic authentication.


then it works fine




We are still (sorta) dealing with the issue, but it came down to issues on the SAP side with their Web Dispatcher not sending the entire header (or something like that).  We also found this post, not sure if it would have made a difference as there was problems beyond that:



We are still looking to get certificates working.