Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • TRTH /
avatar image
Question by Yarch · Sep 26, 2017 at 06:04 PM · trthv2rest apir

No HTTP resource was found when use REST API in R

Hi all,

I'm trying to use REST API to connect TRTH in R, now I'm having problem with my code

library(httr)
uri1 <- "https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/HistoricalSearch"
token1 <- paste("Token", cred[2], sep = " ")

body1 <- '{ "Request": { "Identifier": "TRI.N", "IdentifierType": "Ric", "Range": { "Start": "2015-11-17T00:00:00.000Z", "End": "2015-11-24T00:00:00.000Z" } } }'

a <- httr::GET(uri1, body = body1, add_headers(Prefer = "respond-async",Authorization = token1)) 
result <- httr::content(a, "parsed", "application/json")

In the above code I save my token in cred[2]

After I run my code, I get this result

$error
$error$message [1]
"No HTTP resource was found that matches the request URI 'https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/HistoricalSearch'."

Looks like I have a wrong URI input, but I just copy this address from sample code.

I appreciate that if anybody can help me with this issue.

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

7 Replies

  • Sort: 
avatar image
Best Answer
Answer by Yarch · Sep 26, 2017 at 09:23 PM

@chavalit.jintamalit

Now I solve this problem, I really appreciate your help

For the convenience for all other guys, here is the correct code .

The mistake I have is httr::POST part

I should declare content_type_json() in the header first

getIdentifier <- function(cred, Identifier, IdentifierType){
  uri1 <- "https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/HistoricalSearch"
  
  part1 <- c('{"Request": {"Identifier": "')
  part2 <- c('","IdentifierType": "')
  part3 <- c('", "Range": {
             "Start": "2015-11-17T00:00:00.000Z",
             "End": "2015-11-24T00:00:00.000Z"}}}')
  token1 <- paste("Token", cred[2], sep = " ")
  request <- paste(part1, Identifier, part2, IdentifierType, part3, sep = "")
  a <- httr::POST(uri1, body = request,
                 add_headers(Prefer = "respond-async",Authorization = token1),
                 content_type_json())
  result <- httr::content(a, "parsed", "application/json")
  return(result)
}
Comment
Christiaan Meihsl

People who like this

1 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
Answer by chavalit.jintamalit · Sep 26, 2017 at 08:03 PM

@Yarch , please refer to the developer guide here

On page number 39th, the uri is correct but it is a HTTP POST method.

But your code seems to use a GET method (httr::GET) ? Please confirm.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
Answer by Yarch · Sep 26, 2017 at 08:09 PM

@chavalit.jintamalit

Thank you for point this out, actually I tried both method. If I use httr:POST I will obtain a different error message

$error $error$message [1] "The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource."

I appreciate your apply, hope to see your feedback soon

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
Answer by chavalit.jintamalit · Sep 26, 2017 at 08:13 PM

@Yarch

This error means that you have not defined Content-Type in your http request header.

Please follow the sample request from the developer guide.

The Content-Type is "application/json"


request.png (56.8 KiB)
Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
Answer by Yarch · Sep 26, 2017 at 08:23 PM

@chavalit.jintamalit

Here is the detailed information I observed, I hope it could be helpful regarding on this issue

Starting from variable "a", my output is incorrect

Here is the output of a

Response [https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/HistoricalSearch] 
Date: 2017-09-27 00:20
Status: 404
Content-Type: application/json; charset=utf-8
Size: 157 B

Based on this description, I think the issue is related to the uri i'm using

And for the The Content-Type you just mention in previous reply, I think I set up the correct format.

For your information, here is another example I write in R, which works fine

getUserInfo <- function(cred){
part1 <- "https://hosted.datascopeapi.reuters.com/RestApi/v1/Users/Users("
part2 <- ")"
uri1 <- paste(part1, cred[1], part2, sep = "")
token1 <- paste("Token", cred[2], sep = " ")
a <- httr::GET(uri1, add_headers(Prefer = "respond-async", Authorization = token1))
result <- httr::content(a, "parsed", "application/json") 
return(result)
}
Comment

People who like this

0 Show 2 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
chavalit.jintamalit ♦♦ · Sep 26, 2017 at 09:00 PM 0
Share

Please refer to page 38th on the developer guide.

From the sample Request, this API call does not require Content-Type nor body.

So it is working as expected.

user.png (106.5 KiB)
avatar image
Yarch · Sep 26, 2017 at 09:05 PM 0
Share

Yes you are right. Thanks for this clarification

avatar image
REFINITIV
Answer by chavalit.jintamalit · Sep 26, 2017 at 08:52 PM

@Yarch

I just did 3 tests on the API calls:

1. POST method following the sample request from developer guide

Request:

POST https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/HistoricalSearch HTTP/1.1
Prefer: respond-async
Content-Type: application/json
Authorization: Token <mytoken>
Cache-Control: no-cache

{
  "Request": {
    "Identifier": "US4592001014",
    "IdentifierType": "Isin",
    "Range": {
      "Start": "2008-01-01T00:00:00.000Z",
      "End": "2008-01-01T00:00:00.000Z"
    }
  }
}

Response:

HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8

{"@odata.context":"https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#Collection(ThomsonReuters.Dss.Api.Search.HistoricalSearchResult)","value":[{"Identifier":"IBM","IdentifierType":"Ric","Source":"","Key":"VjF8MHgzMDAwMDAwMDAwMDAwMDAwfDB4MzAwMDAwMDAwMDAwMDAwMHx8fHx8fHxJQk18","Description":"Historical Instrument","InstrumentType":"Unknown","Status":"Valid","DomainCode":"6","FirstDate":"1996-01-02T00:00:00.000Z","LastDate":"2017-09-26T00:00:00.000Z","History":[]},...<a lot of entries here>...}

2. POST method with incorrect Content-Type header

Request:

POST https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/HistoricalSearch HTTP/1.1
cache-control: no-cache
Prefer: respond-async
Content-Type: application/octet-stream
Authorization: Token <mytoken>

{
  "Request": {
    "Identifier": "US4592001014",
    "IdentifierType": "Isin",
    "Range": {
      "Start": "2008-01-01T00:00:00.000Z",
      "End": "2008-01-01T00:00:00.000Z"
    }
  }
}

Response:

HTTP/1.1 415 Unsupported Media Type
Cache-Control: no-cache
Content-Length: 118
Content-Type: application/json; charset=utf-8

{"error":{"message":"The request entity's media type 'application/octet-stream' is not supported for this resource."}}

3. GET method

Request:

GET https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/HistoricalSearch HTTP/1.1
cache-control: no-cache
Prefer: respond-async
Content-Type: application/json
Authorization: Token <mytoken>

Please note that HTTP GET method cannot contain body.

Response:

HTTP/1.1 404 Not Found
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8

{"error":{"message":"No HTTP resource was found that matches the request URI 'https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/HistoricalSearch'."}}

I do not put all the detail headers here, just only related headers to troubleshoot the issue.

Hope this is more clear now.

Comment
Yarch

People who like this

1 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
Yarch · Sep 26, 2017 at 09:47 PM 0
Share

@chavalit.jintamalit

Your reply is the key issue that help me solve this problem.

Since this issue is related to R, I post the correct solution for this issue and accept it as highlight answer.

If you want this reply to be highlight, I will cancel my accept and highlight this long reply from you

avatar image
Answer by Yarch · Sep 26, 2017 at 09:03 PM

@chavalit.jintamalit

Thanks for your clarification. It makes sense. And I notice that the 3rd example you provide has the identical error that I have

So maybe I need to declare this Content type at the beginning of my code.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
11 People are following this question.

Related Questions

Trying to get fields list of the ElektronTimeSeries using GET Action on TRTHV2 REST API

TRTH Rest API

Data missing for 3549.T(3398.T)

I am accessing TRTH v2 data using API and using python as main language

Consecutive intraday-data extractions differ in their contents (TRTHv2)

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges