Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
27 1 2 6

Fetching NewsStory via API Not Working (C#/.NET Framework)

// Retrieve the most recent headline about Apple
var headline = Headlines.Definition().Query("L:EN and Apple")                                         .Count(1)                                         .GetData(); if (headline.IsSuccess) {     Console.WriteLine("StoryID: "+ headline.Data.Headlines[0].StoryId);     // Retrieve the story based on the story ID     var story = Story.Definition(headline.Data.Headlines[0].StoryId).GetData();     Console.WriteLine($"\nHeadline: {headline.Data.Headlines[0].HeadlineTitle}");     if (story.IsSuccess)     {         Console.WriteLine($"\nStory (Plain text): {story.Data.NewsStory}");         Console.Write("\n<Enter> to retrieve Html formatted version..."); Console.ReadLine();         Console.WriteLine($"\nStory (HTML): {story.Data.HtmlNewsStory}");     }     else         Console.WriteLine($"Problem retrieving the story: {story.HttpStatus}"); } else     Console.WriteLine($"Problem retrieving the headline: {headline.HttpStatus}");

I'm trying to fetch the News Story's body using the .NET library in C#. I'm running the sample project (2.3.03-News-Story). story.Data.NewsStory as well as story.Data.HtmlNewsStory are both returning as null. I have not modified the sample project code, except for printing out the StoryID, which is "urn:newsml:newsroom:20230709:nNRAp69095:0"

Any idea on why both "story.Data.NewsStory" and "story.Data.HtmlNewsStory" are returning as null? FYI, the news item is succesfully being found and story.IsSuccess is true.

eikon-data-apiworkspace#technology#productnews
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.

Hi @cmendolsohn

Can you confirm the version of the Refinitiv.Data library you are using? A new release was just recently created addressing an issue extracting the News Story.

I'm on 1.0.0-beta4. I see an upgrade to 1.0.0-beta5. Does the upgraded version address this issue?

Does the upgrade affect any other functionality, for example news streaming, because I don't want to disrupt my other workflows?

Hello @cmendolsohn

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?


If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,


AHS

Upvotes
Accepted
79.4k 253 52 74

@cmendolsohn

I am using 1.0.0-beta5 and it can return that news story properly.

However, after downgrading to 1.0.0-beta4, I got null for this news story.

 var story = Story.Definition("urn:newsml:newsroom:20230710:nNRAp6cmnn:0").GetData();

                            Console.WriteLine($"\nHeadline: {headline.Data.Headlines[0].HeadlineTitle}");

                            if (story.IsSuccess)
                            {
                                Console.WriteLine($"\nStory (Plain text): {story.Data.NewsStory}");
                                if (story.Data.NewsStory == null)
                                {
                                    Console.Write("\nBlank Story");
                                    Console.ReadLine();

                                }
                             
                            }

Nick is correct. Please upgrade to 1.0.0-beta5.


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.

Upvotes
79.4k 253 52 74

@cmendolsohn

Thank you for reaching out to us.

I can run the code properly with a Console application and .NET Framework 4.8.

You may need to enable logging in the API to verify what the problem is.

using Refinitiv.Data;
...
Log.Level = NLog.LogLevel.Debug;
Log.Output = (loginfo, parms) => Console.WriteLine($"Application: {loginfo.Level} - {loginfo.FormattedMessage}");
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.

Can you confirm that the story's text (and not just the headline) is printing in your Console Window? That is where I'm running into issues. The headline is able to be retrieved, but the story itself is not. Please see attached screenshot and pasted Logs.

refinitiv-body-fetch-failed.png

2023-07-10 02:41:58.1867|Debug|Refinitiv.Data.Delivery.Request.EndpointDefinition|4|Preparing Endpoint GET request http://localhost:9000/api/rdp/data/news/v1/headlines?query=L%3AEN and Apple&limit=1

2023-07-10 02:41:58.8779|Debug|Refinitiv.Data.Content.News.HeadlinesDefinition|22|News Headline retrieval completed. Next page cursor: eyJxd.... Count specified: 1. Headlines received: 1

2023-07-10 02:41:58.8779|Debug|Refinitiv.Data.Delivery.Request.EndpointDefinition|12|Preparing Endpoint GET request http://localhost:9000/api/rdp/data/news/v1/stories/urn%3Anewsml%3Anewsroom%3A20230710%3AnNRAp6cmnn%3A0

2023-07-10 02:42:09.6310|Debug|Refinitiv.Data.Core.DesktopSessionCore|1|Disposing Desktop Session

These are my current API settings (currently on a trial version):
refinitiv-api-key-types.png


Yes, I can get the story.

1688972477383.png

Can you access this news (urn:newsml:newsroom:20230710:nNRAp6cmnn:0) via the News Monitor App?

1688972877190.png

1688972477383.png (82.2 KiB)
1688972877190.png (116.8 KiB)
Show more comments
Upvotes
79.4k 253 52 74

You can enable network tracing in the .NET Framework by adding the following configurations in the App.config file.

<configuration>
...
<system.diagnostics>  
    <sources>  
      <source name="System.Net" tracemode="includehex" maxdatasize="102400">  
        <listeners>  
          <add name="System.Net" />  
        </listeners>  
      </source>  
      <source name="System.Net.Cache">  
        <listeners>  
          <add name="System.Net" />  
        </listeners>  
      </source>  
      <source name="System.Net.Http">  
        <listeners>  
          <add name="System.Net" />  
        </listeners>  
      </source>  
      <source name="System.Net.Sockets">  
        <listeners>  
          <add name="System.Net" />  
        </listeners>  
      </source>  
      <source name="System.Net.WebSockets">  
        <listeners>  
          <add name="System.Net" />  
        </listeners>  
      </source>  
    </sources>  
    <switches>  
      <add name="System.Net" value="Verbose" />  
      <add name="System.Net.Cache" value="Verbose" />  
      <add name="System.Net.Http" value="Verbose" />  
      <add name="System.Net.Sockets" value="Verbose" />  
      <add name="System.Net.WebSockets" value="Verbose" />  
    </switches>  
    <sharedListeners>  
      <add name="System.Net" type="System.Diagnostics.TextWriterTraceListener" initializeData="network.log" />  
    </sharedListeners>  
    <trace autoflush="true" />  
  </system.diagnostics>  
...
</configuration>

With these configurations, the network.log file will be created. You can check the HTTP response of the News Story request.

1688978136912.png



1688978136912.png (54.2 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.

Related to nick.zincone's comment above on my original post: "A new release was just recently created addressing an issue extracting the News Story.".

What version of Refinitiv.Data are you using?

Upvotes
17.5k 82 39 63

Hi @cmendolsohn

I would recommend you download the latest example package which includes release notes for changes in this release. You can try isolated examples to confirm behavior. Regarding "news streaming", can you elaborate what specific API/Example you are referring to? The main News change was to react to the changes in the Desktop News Story extraction. I would try example 2.3.03-News-Story in the new package to confirm expected behavior.

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.

Thanks, I will try your suggestions when I get some free time later today. By "news streaming", I mean streaming news via the Pricing Library.

Upvotes
27 1 2 6

After upgrading Refinitiv.Data Nuget package to 1.0.0-beta5, I am now able to get a response from the server that includes the story's Body. To answer @Jirapongse previous issue of why some news items will not retrieve a Body, if the news source is a Web News source "urn:link:webnews", the Body will not be available, which I guess is expected behavior because even in the News Monitor tool, selecting a Web News item opens an external browser link.


I'm currently trying to optimize performance, and instead of querying for the StoryID using Headlines.Definition().Query() (which introduces additional latency), I'm trying to directly create the StoryID as such, where PNAC is the "PNAC" field of an incoming news item from the Pricing Library's news streaming mechanism.

string storyID = "urn:newsml:newsroom:"+ DateTime.Now.ToString("yyyyMMdd") + ":"+PNAC+":0".


Can I get confirmation that this is the proper formatting of the StoryID used to find a News Story, and what is the ":0" for? In what scenarios is it not ":0"?

Moreover, using this workflow seems to run into significant performance issues, as the news item's Body will not be available for retrieval by the server (404 Story Not Found error) until at least 2-3 seconds after the headline is picked up by the news streaming mechanism. Is there anyway to overcome this performance issue? It doesn't seem right that the News Body takes 2-3 seconds to be available after the headline is available.


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.

Upvotes
17.5k 82 39 63

Hi @cmendolsohn

I'm glad you were able to get the news story.

Regarding the creation of the story ID based on the streaming field, I would suggest you reach out to a News content specialist as they can confirm your approach and to better understand the delay you are experiencing with the story. You should be able to access a content specialist via the Refinitiv Helpdesk.

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.

Upvotes
79.4k 253 52 74

@cmendolsohn

The number after PNAC could be the version number.

1689130846009.png

However, I could not find it in the document. Please contact the content support team directly via the Refinitiv Helpdesk to confirm this, as mentioned by my colleague.


1689130846009.png (61.2 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.