Side by side api: launched app does not take into account Context

Capture.PNGHello Team,

I am trying to open a news (or quote, or overview) using SXS in python.

Ping and Handhsake work fine but when I launch an app, the app opens, loads but does'nt load the right context (ric)

import pandas as pd
import requests
#ping server
surl='http://127.0.0.1:9000/ping';
r = requests.get(url = surl)
r.text

Output: '9000'

#Handshake
surl='http://127.0.0.1:9000/sxs/v1';
dbody = {'command':'handshake', 
        'productId':pyproductID, 
        'appKey':myappkey}
r = requests.post(url = surl, data = dbody)
response=pd.read_json(r.text)
sessionToken=response['sessionToken'][0]
r.text

Output: json, isSuccess: true

dbody = {'command':'launch', 
        'sessionToken': sessionToken, 
        'appId':'News',
        'context': {"entities": [{'RIC': 'TRI.TO'}]}
        }
r = requests.post(url = surl, data = dbody)
r.text

Output: json, isSuccess: true, got an instance ID


The news app will open and load... the last EIKON opened ric.

Also, is there a way to pass a news ID to the news app (alternatively: what is the best way to open a news from id, using SXS)?

Thank you very much for your answer

BR

PS: could'nt post screen shot (34kb....)???

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @MF

    Please try the following code instead.

    import json
    dbody = {'command':'launch', 
            'sessionToken': sessionToken, 
            'appId':'News',
            'context': {"entities": [{'RIC': 'TRI.TO'}]}
            }
    r = requests.post(url = surl, data = json.dumps(dbody), headers={"Content-Type":"application/json"})
    r.text

    Or,

    dbody = {'command':'launch', 
            'sessionToken': sessionToken, 
            'appId':'News',
            'context': {"entities": [{'RIC': 'IBM.N'}]}
            }
    r = requests.post(url = surl, json = dbody)
    r.text

    For StoryId, you can use it with "NewsQuery".

    dbody = {'command':'launch', 
            'sessionToken': sessionToken, 
            'appId':'News',
            'context': {"entities": [{'NewsQuery': 'urn:newsml:reuters.com:20191114:nNenT48kC:2'}]}
            }
    r = requests.post(url = surl, json = dbody)
    r.text

Answers

  • Thank you very much Jirapongse,

    Just tested your code lines and it works just as expected.

    BR
    MF