• mesmail
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

How can I access the first element in a set?  Example in a list, you can use this to get the first element in the list  

 

Integer x = xList.get(0);

 

What would be a quick equivalent way of doing this in a set?

In the following SF class code:

 

//2. make webservice call to create Rally Attachment
req.setEndpoint(RallyURL+':443/slm/webservice/1.26/attachmentcontent/create');
req.setMethod('POST');

req.setHeader('Authorization', authorizationHeader);
req.setHeader('Content-Type','text/xml');

String body;
body = '{"Content":"'+EncodingUtil.base64Encode(att.Body)+'"}';

req.setBody(body);

//send the request
res = http.send(req);
System.debug('***res1: ' + res.getBody());

 

 

I am getting the following error on response:

 

09:49:09.411 (1411487000)|USER_DEBUG|[79]|DEBUG|***res1: <?xml version="1.0" encoding="UTF-8"?>
<CreateResult rallyAPIMajor="1" rallyAPIMinor="26">
<Errors>
<OperationResultError>Cannot parse input stream as XML document: Error on line 1: Content is not allowed in prolog.</OperationResultError>
</Errors>
<Warnings />
</CreateResult>


Can you please assist me?

 

I am trying to add attachment to a defect in Rally using http post from Salesforce class.  Has anyone done this successfully to provide me with an example?  Thanks in advance

How can I access the first element in a set?  Example in a list, you can use this to get the first element in the list  

 

Integer x = xList.get(0);

 

What would be a quick equivalent way of doing this in a set?

In the following SF class code:

 

//2. make webservice call to create Rally Attachment
req.setEndpoint(RallyURL+':443/slm/webservice/1.26/attachmentcontent/create');
req.setMethod('POST');

req.setHeader('Authorization', authorizationHeader);
req.setHeader('Content-Type','text/xml');

String body;
body = '{"Content":"'+EncodingUtil.base64Encode(att.Body)+'"}';

req.setBody(body);

//send the request
res = http.send(req);
System.debug('***res1: ' + res.getBody());

 

 

I am getting the following error on response:

 

09:49:09.411 (1411487000)|USER_DEBUG|[79]|DEBUG|***res1: <?xml version="1.0" encoding="UTF-8"?>
<CreateResult rallyAPIMajor="1" rallyAPIMinor="26">
<Errors>
<OperationResultError>Cannot parse input stream as XML document: Error on line 1: Content is not allowed in prolog.</OperationResultError>
</Errors>
<Warnings />
</CreateResult>


Can you please assist me?

How can I access the first element in a set?  Example in a list, you can use this to get the first element in the list  

 

Integer x = xList.get(0);

 

What would be a quick equivalent way of doing this in a set?

In the following SF class code:

 

//2. make webservice call to create Rally Attachment
req.setEndpoint(RallyURL+':443/slm/webservice/1.26/attachmentcontent/create');
req.setMethod('POST');

req.setHeader('Authorization', authorizationHeader);
req.setHeader('Content-Type','text/xml');

String body;
body = '{"Content":"'+EncodingUtil.base64Encode(att.Body)+'"}';

req.setBody(body);

//send the request
res = http.send(req);
System.debug('***res1: ' + res.getBody());

 

 

I am getting the following error on response:

 

09:49:09.411 (1411487000)|USER_DEBUG|[79]|DEBUG|***res1: <?xml version="1.0" encoding="UTF-8"?>
<CreateResult rallyAPIMajor="1" rallyAPIMinor="26">
<Errors>
<OperationResultError>Cannot parse input stream as XML document: Error on line 1: Content is not allowed in prolog.</OperationResultError>
</Errors>
<Warnings />
</CreateResult>


Can you please assist me?

I'm trying to send a file that's attached to a Case out of my APEX Code, I'm trying to 'form' the POST request and pass the attachments body in the post request as follows:

 

HttpRequest req = new HttpRequest();
req.setHeader('Authorization','Basic '+EncodingUtil.base64Encode(Blob.valueOf('----:0000')));
req.setHeader('Content-Type','multipart/form-data; boundary=-----------------------------153501500631101');
req.setHeader('Content-Length',String.valueOf(attachments[0].BodyLength));
req.setMethod('POST');  
req.setEndpoint(endPoint+'/createattachment');
		
String body = '-----------------------------153501500631101\r\n';
body = body + 'Content-Disposition: form-data; name="Filedata"; filename="'+attachments[0].Name+'"\r\n';
body = body + 'Content-Type: '+attachments[0].ContentType+'\r\n\r\n';
body = body + attachments[0].Body + '\r\n';
body = body + '-----------------------------153501500631101--\r\n';
    req.setbody(body);
try{
  Http http = new Http();
  HTTPResponse res = Http.send(req);
}

 Everything looks good in the debugger (which reports the body as being 'Blob', even though it's a string ?) 

 

And the server sends back a 200, but the attachment doesn't appear?

 

I've added this question to stackoverflow.com: http://stackoverflow.com/questions/10215808/post-multipart-form-data-out-of-salesforce-com-apex