Skip to content

401 Unauthorized Error #5

@samirkhan70

Description

@samirkhan70

Hi Nate,

I am executing below code.

String body = system.label.MAFLF_SPBody;
String ep = 'https://pprojectstest.xxx.ae/SF/_vti_bin/copy.asmx';
system.debug('system.label.MAFLF_SPBody-->'+system.label.MAFLF_SPBody);
HttpClient httpObj = new HttpClient('domain\USERNXXXXXXX','PASSXXXX',true);
HttpRequest req = new HttpRequest();
req.setBody(body);
req.setMethod('POST');
req.setEndpoint(ep);

Map<String,String> headerMap = new Map<String,String>();
headerMap.put('Content-Type','text/xml;charset=UTF-8');
headerMap.put('Accept-Encoding','gzip,deflate');
headerMap.put('Content-Length','379');
headerMap.put('HOST','pprojectstest.xxx.ae');
headerMap.put('SOAPAction','http://schemas.microsoft.com/sharepoint/soap/GetItem');
headerMap.put('Connection','Keep-Alive');

HttpResponse res = httpObj.send(req,headerMap);

System.debug('Response**:' + res);
System.debug('Response**:' + res.getBody());

And getting the error : System.HttpResponse[Status=Unauthorized, StatusCode=401]

I am not even able to get the challenge in the first reponse with the type1 message. I am able to hit the service though with SOAP UI.

Any help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions