Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • TREP APIs /
avatar image
Question by billy.w.cunningham · Mar 21, 2019 at 10:47 AM · javascriptposthtmlids

How to make html POST to IDS

Background. I have IDS server running on host padh4, port 8500. I want to request a snapshot from IDS, and filter FIDs BID and ASK.

The following works ok from the command line:

COMMAND:
curl "http://padh4:8500/ids-rest/json/quote/" -d '{"item": ["CSCO.O"],"filter": ["BID","ASK","TRDPRC_1"],"service": "IDN_RDF","token": "rharris"}'
RESULT:
{"stsCode":0,"stsTxt":"OK","result":[{"_service":"IDN_RDF","_qos":"RT0","_item":"CSCO.O","stsCode":0,"stsTxt":"OK","chainLink":[],"TRDPRC_1":"53.68","BID":"53.68","ASK":"53.69"}]}

I am trying to achieve the same result with an html page, code shown below.

<html>
<head>
<title>Form Example</title>
<script LANGUAGE="JavaScript" type="text/javascript">
function display() {
  message = "{"; 
  message += "\"item\" :"        + document.form1.item.value        + ",";
  message += "\"filter\" :"      + document.form1.filter.value      + ",";
  message += "\"service\" :"     + document.form1.service.value     + ",";
  message += "\"user\" :"        + document.form1.user.value        + ",";
  message += "\"expandChain\" :" + document.form1.expandChain.value + ",";
  message += "\"emptyLink\" :"   + document.form1.emptyLink.value   + ",";
  message += "\"chainLink\" :"   + document.form1.chainLink.value;
  message += "}";
 
  var form = document.createElement("form");
  form.setAttribute("method", "post");
  form.setAttribute("action", "http://padh4:8500/ids-rest/json/quote/");
  var hiddenField = document.createElement("input");
  hiddenField.setAttribute("type", "hidden");
  hiddenField.setAttribute("name", "key");
  hiddenField.setAttribute("value", message);
  form.appendChild(hiddenField);
  document.body.appendChild(form);
  form.submit();
}
</script>
</head>
<body>
<h1>Form Example</h1>
Enter the following information. When you press the Display button,
the data you entered will be displayed in a pop-up window.
<form name="form1">
<p><b>Item:</b> <input TYPE="TEXT" SIZE="20" NAME="item">
</p>
<p><b>Filter:</b> <input TYPE="TEXT" SIZE="30" NAME="filter">
</p>
<p><b>Service: </b> <input TYPE="TEXT" SIZE="15" NAME="service">
</p>
<p><b>User: </b> <input TYPE="TEXT" SIZE="15" NAME="user">
</p>
<p><b>Expand Chain: </b> <input TYPE="TEXT" SIZE="15" NAME="expandChain">
</p>
<p><b>Empty Link: </b> <input TYPE="TEXT" SIZE="15" NAME="emptyLink">
</p>
<p><b>Chain Link: </b> <input TYPE="TEXT" SIZE="15" NAME="chainLink">
</p>
<p><input TYPE="BUTTON" VALUE="Send POST" onClick="display();"></p>
</form>
</body>
</html>

This page connects to padh4 on port 8500 ok, and seems to make the POST ok. The javascript takes the form data and builds a string, which is submitted via a hidden table. However, IDS returns the following error:

{"stsCode":402,"stsTxt":"PARSE_UNICODE_ERROR"}

The chrome debugger shows my POST was submitted as the value to a variable called "key". The format is close but not correct, hence the 402 error from IDS.

My issue is how to get the POST correctly formatted. Do I need to JSON.stringify the message? Or build it completely manually? How to get rid of the 'key' in the response?

Thanks in advance for all help.

capture.png (49.1 KiB)

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.

6 Replies

  • Sort: 
avatar image
Best Answer
Answer by billy.w.cunningham · Mar 25, 2019 at 08:41 AM

Gurpreet, we got the answer. The file item_input.html, which comes with IDS, shows how to construct the POST message and submit it correctly. Thanks for all your help.

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 Gurpreet · Mar 21, 2019 at 11:26 AM

@billy.w.cunningham I don't have an IDS to test it out anymore, but it looks like that the form message you are submitting is incorrect. There are additional + in the form data and form values aren't in double quotes either.

You are also missing the token key - which is present in the CURL command.

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 billy.w.cunningham · Mar 21, 2019 at 11:57 AM

Thanks Gurpreet, i did change 'user' to 'token'. I still need to get rid of the +s and that should be pretty close.

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 billy.w.cunningham · Mar 21, 2019 at 12:32 PM

This curl command works fine with IDS:

curl "http://padh3:8500/ids-rest/json/quote/" -d '{"item": ["CSCO.O"],"filter": ["BID","ASK","TRDPRC_1"],"service": "IDN_RDF","token": "rharris"}'

Is there a way to get this same result from an html form?

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 Gurpreet · Mar 21, 2019 at 12:37 PM

I'll try to create a sample form and post here.

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 Gurpreet · Mar 22, 2019 at 03:00 PM

Hi @billy.w.cunningham You can try the attached sample. I am not able to test it because of no access to IDS, so you might have to tweak it.

idstest.zip


idstest.zip (917 B)
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 >
9 People are following this question.

Related Questions

Can I subscribe to my own POSTs on same RFA connection?

  • 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