I need to upload files using the Session tag within the protocol. The process involves receiving images as Base64-encoded strings, which I then convert into a byte[]
format. To attach the files, I use the SetParameterBinary
method to set the file parameter.
However, I'm encountering a 500 Internal Server Error in response.
<- 11:01:09 - POST https://.../troubleTicket/2505H25831/attachment
-> 11:01:09 - HTTP/1.1 500 Internal Server Error
-> 11:01:09 - Get for createAttachmentResponseContent (status code: HTTP/1.1 500 Internal Server Error), returned VT_BSTR : {"code":-1,"message":"Internal Server Error","description":"The server encountered an unexpected condition which prevented it from fullfilling the request.","infoURL":"/troubleTicket/2505H25831/attachment"}
Example of a working request in Postman:
Relevant C# code:
private void PrepareAndTriggerCreateAttachmentRequest(AttachmentRequest attachmentRequestBody, string ticketId)
{
SetFileRequestParameter(attachmentRequestBody.File);
SetOtherRequestParameters(attachmentRequestBody, ticketId);
_protocol.CheckTrigger((int)Trigger.FromQActionExecuteCreateAttachmentRequest_31);
}
private void SetFileRequestParameter(byte[] file) => _protocol.SetParameterBinary(Parameter.createattachmentrequestfile_652, file);
private void SetOtherRequestParameters(AttachmentRequest attachmentRequestBody, string ticketId)
{
var parameters = new[]
{
Parameter.createattachmentdynamicurl_1001,
Parameter.createattachmentrequestdescription_653,
Parameter.createattachmentrequestlabel_654,
Parameter.createattachmentrequesttype_655,
};
var values = new object[]
{
$"{TicketBaseUrl}/{ticketId}/attachment",
attachmentRequestBody.Description,
attachmentRequestBody.Label,
attachmentRequestBody.Type,
};
_protocol.SetParameters(parameters, values);
}
Relevant protocol.xml parts:
<Session id="4" name="createAttachment">
<Connection id="1" name="createAttachment">
<Request verb="POST" pid="1001">
<Headers>
<Header key="X-Client-User-Id" pid="104"/>
<Header key="Authorization" pid="105"/>
<Header key="Content-Type">multipart/form-data</Header>
</Headers>
<Parameters>
<Parameter key="file" pid="652" />
<Parameter key="description" pid="653" />
<Parameter key="label" pid="654" />
<Parameter key="type" pid="655" />
</Parameters>
</Request>
<Response statusCode="503">
<Content pid="603"></Content>
</Response>
</Connection>
</Session>
<Param id="652" trending="false">
<Name>createAttachmentRequestFile</Name>
<Description>Create Attachment Request File</Description>
<Type>read</Type>
<Interprete>
<RawType>other</RawType>
<LengthType>next param</LengthType>
</Interprete>
</Param>
I'm seeing different behavior between a request sent via Postman and my own implementation. Since it's HTTPS, I can't directly inspect the raw traffic. Has anyone dealt with this before?