Hi, I am trying to call the DSS REST API with the following Javascript code
exports.getEOD = function(token, success, failure) { var https = require('https'); var url = 'hosted.datascopeapi.reuters.com'; var path = "/RestApi/v1/Extractions/ExtractWithNotes"; var response = '' var options = { hostname: url, path: path, method: 'POST', headers: { 'Authorization': 'Token ' + token, 'X-Client-Version': 'restapiv1.10.2.884.0', 'Prefer': 'respond-async, wait=5' } }; var postData = JSON.stringify({ "ExtractionRequest": { "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.EndOfDayPricingExtractionRequest", "ContentFieldNames": [ "Asset Status", "Asset Type", "Bid Price", "Currency Code", "CUSIP", "File Code", "Ask Price", "High Price", "Low Price", "Mid Price", "Volume", "Net Asset Value", "Offer Price", "Official Close Price", "Open Price", "Previous Close Price", "RIC", "Security Description", "SEDOL", "Ticker", "Trade Date" ], "IdentifierList": { "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList", "InstrumentIdentifiers": [ { "Identifier": "191216100", "IdentifierType": "Cusip" }, { "Identifier": "2005973", "IdentifierType": "Sedol" }, { "Identifier": "AAPL.OQ", "IdentifierType": "Ric" } ] }, "Condition": null } }) var req = https.get(options, function(res) { if (res.statusCode == 200) { res.setEncoding('utf8'); res.on('data', function(chunk) { response = response + chunk }); res.on('end', function() { success(response) }) } else{ console.log('statusCode: ' + res.statusCode); failure(JSON.stringify(res.headers)) } }); req.on('error', function(e) { failure(e.message) }); console.log(postData) req.write(postData); req.end(); }
I get the following response
statusCode: 400
EOD Error: {"cache-control":"no-cache","pragma":"no-cache","content-type":"application/json; odata.metadata=minimal; odata.streaming=true","expires":"-1","server":"Microsoft-IIS/7.5","odata-version":"4.0","x-request-execution-correlation-id":"e26efcaf-e571-4816-92b1-07e232a7b6cd","x-app-id":"Custom.RestApi","x-app-version":"10.4.77.0","x-powered-by":"ASP.NET","date":"Fri, 04 Mar 2016 14:56:37 GMT","content-length":"2356"}
What could the problem be?