Access Datastream Web Services Error Messages
When you make a historical data request from Datastream™ Web Services from Refinitiv™, sometimes the request returns an error instead of data. Use this workflow to access Datastream Web Services error messages.
The history function returns errors in the matlab.net.http.ResponseMessage object. For example, suppose that you enter an
invalid security name for the sec input argument. The resulting output has
this form:
d =
ResponseMessage with properties:
StatusLine: 'HTTP/1.1 200 OK'
StatusCode: OK
Header: [1×6 matlab.net.http.HeaderField]
Body: [1×1 matlab.net.http.MessageBody]
Completed: 0
Access the Body property using dot notation.
d.Body
ans =
MessageBody with properties:
Data: [1×1 struct]
Payload: []
ContentType: [1×1 matlab.net.http.MediaType]
ContentCoding: [0×0 string]To access the text of the error message, access the nested structure
DataResponse stored in the Data property.
d.Body.Data.DataResponse
ans =
struct with fields:
AdditionalResponses: []
DataTypeNames: []
DataTypeValues: [3×1 struct]
Dates: []
SymbolNames: []
Tag: ''Then, access the SymbolValues field in the
DataTypeValues structure array.
d.Body.Data.DataResponse.DataTypeValues(1).SymbolValues
ans =
struct with fields:
Currency: []
Symbol: 'YYY'
Type: 0
Value: '$$ER: E100,INVALID CODE OR EXPRESSION ENTERED'Fix your code based on the error message in the Value field.