I'm trying to send an http request to a remote web service, the web service requires I POST an httpheader formatted as { "username" : "theusername", "password" : "thepassword" } so I've created a string variable named loginstring that is formatted as '"theusername", "password" : "thepassword" }' and set my header request as req.setHeader('{ "username" : ', loginstring); I'm getting a System.CalloutException: Attempt to use invalid header in request. I'm trying to figure out if this error is coming from sfdc or the target web service, from the debug log I'm seeing 0 of 100 callouts so I'm assuming that the error is coming from sfdc.
if(loginstring != null){
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setMethod('POST' ); // Method Type
req.setEndpoint('web210.ntree.com/twig-cstc3/v1/login');//salestree url
req.setHeader('Content-Type','application/json');
req.setHeader('{ "username" : ', loginstring);
res = http.send(req);
if(res.getBody() != null){
Is this an sfdc side error and if so what am I doing wrong?