According to provided API, the request must include the following header:
x-http-request-info:{"clientRequestId":{"sessionId":"some_ID_number","requestId":"123456789"}}
If I use the webread, I can construct this as
requestId = struct('clientRequestId',struct('sessionId',sessionId,'requestId',requestId));
header = {'x-http-request-info' jsonencode(requestId)};
options = weboptions('RequestMethod','GET','HeaderFields',header);
response = webread(url, options);
The problem with this approach is that webread does not return response-header, so I have to use the low level http commands.
However matlab.net.http.RequestMessage does not accept the above request header. I have tried to use matlab.net.http.HeaderField:
field1 = matlab.net.http.HeaderField('sessionId', sessionId);
field2 = matlab.net.http.HeaderField('requestId', requestId);
requestInfo = matlab.net.http.HeaderField('clientRequestId',[field1, field2]);
matlab.net.http.HeaderField('x-http-request-info', requestInfo);
method = matlab.net.http.RequestMethod.GET;
request = matlab.net.http.RequestMessage(method,header);
response = send(request,uri);
The response comes back with code 400 BadRequest
ResponseMessage with properties:
StatusLine: 'HTTP/1.1 400 '
Header: [1×8 matlab.net.http.HeaderField]
Body: [1×1 matlab.net.http.MessageBody]
response.Body.Data.messages
key: 'request.header.invalid.x-http-request-info'
message: 'Der Header 'x-http-request-info' ist fehlerhaft.'
What is the correct way to specify this particular header?
Many thanks in advance!
Victor