I have two byte array in the angularjs application. I want to pass two byte array to api end point in the body as a post operation.
function getPayload(byteArray1, byteArray2) {
return {
"byteArrayInfo1": byteArray1,
"byteArrayInfo2": byteArray2
};
}
var executePostRequest = function (command, byteArray1, byteArray2) {
return $http({
method: 'POST',
headers: { 'Content-Type': 'application/octet-stream' },
data: getPayload(byteArray1,byteArray2),
url: env.endPointBasePath + command
});
};
When i am debugging to dot net api end point, it is not getting two byte array. I tried changing content-type to 'Content-Type': 'application/json'. It did not work.
My concern here is now, is it good to try to pass two byte array in one post call? Is it good practice? I would be happy if there is technique in javascript/angularjs to merge two byte arrays and split in app api end point.
App api end point is self hoisted owin based appliation. I was trying to retrive the body from context request body and map it to ByteArrayPayload class.
private static ByteArrayPayload ExtractContent(OwinContext context)
{
if (ContentLengthIsNullOrZero(context.Request.Headers.ContentLength))
{
return null;
}
int contentLength = Int32.Parse(context.Request.Headers.ContentLength);
var content = context.Request.Body.Read(contentLength);
//map content to ByteArrayPayload
return new ByteArrayPayload ();
}
public class ByteArrayPayload{
public byte[] ByteArrayInfo1 {get;set;}
public byte[] ByteArrayInfo2 {get;set;}
}