Trying to use permid file match and receive error Failed to resolve API Key variable request.head...

...er.X-AG-Access-Token

Good day

I am trying to use permID file match by hitting https://api.thomsonreuters.com/permid/match/file

I can use the entity search API with no errors, but with the file match I am getting the following error
{
"fault": {
"faultstring": "Failed to resolve API Key variable request.header.X-AG-Access-Token",
"detail": {
"errorcode": "steps.oauth.v2.FailedToResolveAPIKey"
}
}
}

I am currently using postman to test and am unsure of what I am doing wrong.

image


When using this access token in the Dev Tools try it out section, I do not receive an error.

Any help is appreciated.

Steven

Welcome!

It looks like you're new here. Sign in or register to get started.

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    I have modified the code.

    1. The path should start with "/"

    2. Add the "x-ag-access-token" in the headers

    3. Add content in the body

    The modified code is:

    var http = require("https"); 

    var options = { "method": "POST", "hostname": "api.thomsonreuters.com", "path": "/permid/match/file", "headers": { "content-type": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "x-openmatch-numberOfMatchesPerRecord": "1", "x-openmatch-dataType": "Organization", "cache-control": "no-cache", "Postman-Token": "101e3dbe-96bf-4b1c-9fce-8dad5f4ff975", "x-ag-access-token" : "token"}};

    var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); });

    res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); });

    req.write("------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"test.csv\"\r\nContent-Type: application/vnd.ms.-excel\r\n\r\nLocalID,Standard Identifier,Name,Country,Street,City,PostalCode,State,Website\r\n1,,Apple,US,\"Apple Campus, 1 Infinite Loop\",Cupertino,95014,California,\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--");

    req.end();

Answers

  • Alex Putkov.1
    Alex Putkov.1 ✭✭✭✭✭

    According to chapter 2.3 of PermID API User Guide, if you want to pass access token as a parameter in the URL rather than as an HTTP header, the parameter name is "access-token" and not "x-ag-access-token".

  • After updating my node code i get the following back in terminal after trying to run node.
    $ node index.js
    <!DOCTYPE html>
    <html>
    <head>
    <title>Error</title>
    <style>
    body {
    width: 35em;
    margin: 0 auto;
    font-family: Tahoma, Verdana, Arial, sans-serif;
    }
    </style>
    </head>
    <body>
    <h1>An error occurred.</h1>
    <p>Sorry, the page you are looking for is currently unavailable.<br/>
    Please try again later.</p>
    </body>
    </html>

    Below is the code in index.js

    const express = require('express')
    const app = express()


    const request = require('request');
    const cors = require('cors');
    // const http = require('http');
    // const https = require('https');
    const util = require('util')


    // Sets an initial port. We"ll use this later in our listener
    const PORT = process.env.PORT || 8080;


    app.use(cors());

    var corsOptions = {
    origin: '*',
    optionsSuccessStatus: 200
    };

    // Service end-point (search)

    // app.get('/upload', function (req, res) {

    // var options = {
    // method: 'GET',
    // url: 'https://api.thomsonreuters.com/permid/match/file?Content-Type=multipart/form-data',
    // headers: {
    // 'cache-control': 'no-cache',
    // 'x-openmatch-dataType': 'Organization',
    // 'x-openmatch-numberOfMatchesPerRecord': '1',
    // 'x-ag-access-token': '96CT8NAgnieeuiYA2YPeNMnbPMfHu4W8'
    // },
    // formData: {
    // file: undefined
    // }
    // };

    // request(options, function (error, response, body) {
    // if (error) throw new Error(error);
    // console.log(response)
    // console.log(body);
    // });

    // });

    // function dataReturned(e) {
    // console.log("Success!");
    // finalRes.end(e);
    // }

    // const server = http.createServer(app)
    // server.listen(PORT, () => {
    // console.log(`app started! at port ${PORT}`);
    // });
    var http = require("https");

    var options = {
    "method": "POST",
    "hostname": "api.thomsonreuters.com",
    "path": "permid/match/file",
    "headers": {
    "content-type": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
    "x-openmatch-numberOfMatchesPerRecord": "1",
    "x-openmatch-dataType": "Organization",
    "cache-control": "no-cache",
    "Postman-Token": "101e3dbe-96bf-4b1c-9fce-8dad5f4ff975"
    }
    };

    var req = http.request(options, function (res) {
    var chunks = [];

    res.on("data", function (chunk) {
    chunks.push(chunk);
    });

    res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
    });
    });

    req.write("------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--");
    req.end();

  • Alex Putkov.1
    Alex Putkov.1 ✭✭✭✭✭

    To troubleshoot this I suggest you capture the HTTP request and response going on the wire. Use an HTTP analyzer or a network sniffer.

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.