question

Upvotes
Accepted
1 1 1 3

How to add HTTP Headers to RDP Financial Contracts API Request

I would like to add the x-tr-applicationid http header to my RDP Financial Contracts API request using the C# .NET library. I don't seem to see a way to add custom HTTP headers with the library.

This is what my request looks like:

Bond.Definition(ticker).Fields(fields).GetDataAsync(ISession).

Is there a way to set custom HTTP headers to the session?


#technology#productrdp-api.nethttp
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvote
Accepted
27.6k 67 18 14

Hello @Marco.Buonastella

Based on my research, the Data Library for .NET Content layer does not expose the API for setting HTTP Header parameter. If you need to set the request's HTTP Header manually, you need the Endpoint feature of the Delivery layer as follows.

EndpointRequest.Definition(endpointUrl).Method(<POST or GET>).HeaderParameter("xxxx", "value1").BodyParameters(<Requesty Body>).GetData();

Example Code:

using Refinitiv.Data.Core;
using Refinitiv.Data.Delivery.Request;
using System;
...
// Create the platform session.
using ISession session = Configuration.Sessions.GetSession();


// Open the session
session.Open();


// ********************************************************************************************
// Basic Endpoint retrieval.
// The specific endpoint URL below contains all required parameters.
// ********************************************************************************************
var endpointUrl = "https://api.refinitiv.com/data/quantitative-analytics/v1/financial-contracts";


var endpoint = EndpointRequest.Definition(endpointUrl).Method(EndpointRequest.Method.POST);


Console.WriteLine("\nRequesting data...");


// Create request object...
var bond = new JObject()
{
    ["fields"] = new JArray("InstrumentTag", "InstrumentDescription", "BondType", "CleanPrice","DirtyPrice", "MarketValueInDealCcy", "IssueDate", "EndDate"),
    ["outputs"] = new JArray("Headers", "Data"),
    ["universe"] = new JArray(new JObject()
    {
        ["instrumentType"] = "Bond",
        ["instrumentDefinition"] = new JObject()
        {
            ["instrumentTag"] = "TreasuryBond_10Y",
            ["instrumentCode"] = "US10YT=RR"
        }
    })
};


var response = endpoint.HeaderParameter("x-tr-applicationid", "value1").BodyParameters(bond).GetData();
Console.WriteLine(response);

Result:

result.png

I hope this information helps.


result.png (15.9 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.