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.
Best Answer
-
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.
0
Answers
-
@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.
0 -
Thanks Gurpreet, i did change 'user' to 'token'. I still need to get rid of the +s and that should be pretty close.
0 -
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?
0 -
I'll try to create a sample form and post here.
0 -
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.
0
Categories
- All Categories
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 613 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 631 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 85 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛