Reputation: 11
Integrating Salesforce to Azuredevops, Creating Issue/Task/Bug to Azuredevops from the Salesforce custom page by using POST method RestApi. Doing the same from postman service by using same url ,accesstoken etc and i am able to create task in the Azuredevops.
But issue is when i try the same from salesforce I am getting the response back as
"System.HttpResponse[Status=Found, StatusCode=302]" and <html><head><title>Object moved</title></head><body> <h2>Object moved to <a href="https://*******.*****.visualstudio.com/_signin*********************
I am using Namedcredential in the salesforce, and written code like below,
Httprequest request = new HttpRequest();
Http http = new Http();
request.setMethod('POST');
request.setEndpoint('callout:Namedcred' + '/*****/******/_apis/wit/workitems/$issue?api-version=6.0' );
request.setHeader('Content-Type', 'application/json-patch+json');
request.setHeader('Authorization', '{!$Credential.Password}');
request.setBody(requestBody);
HttpResponse response = http.send(request);
I tried the same from the postman service and everything working good and also getting 200 OK status
Upvotes: 1
Views: 943