ankitgaur
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017
01:44 AM
How to pass request with body part in HTTP POST method api request ?
We are making following API Call in Postman successfully:
For try: Copy the below given code into a JSON file & IMPORT created json file in POSTMAN.
Where "rawModeData": "{\"email\":\"abc@tudip.com\"}" is the BODY Part of the request.
How to make Above POSTMAN api (Above json is an Export of POSTMAN api call) call in ROKU ?.
For try: Copy the below given code into a JSON file & IMPORT created json file in POSTMAN.
{
"id": "5e9021f6-02ea-9846-5380-5b3d58a55d04",
"name": "forgotpassword API on POSTMAN",
"requests": [
{
"id": "657318a8-70a5-065d-e9c5-1b7fac76bda7",
"headers": "Content-Type: application/json\n",
"url": " http://ec2-54-244-62-69.us-west-2.compute.amazonaws.com:80/v1/users/auth/password/reset/",
"pathVariables": {},
"preRequestScript": null,
"method": "POST",
"collectionId": "5e9021f6-02ea-9846-5380-5b3d58a55d04",
"data": [],
"dataMode": "raw",
"name": " http://ec2-54-244-62-69.us-west-2.compute.amazonaws.com:80/v1/users/auth/password/reset/",
"description": "",
"descriptionFormat": "html",
"time": 1489131187724,
"version": 2,
"responses": [],
"tests": null,
"currentHelper": "normal",
"helperAttributes": {},
"rawModeData": "{\"email\":\"abc@tudip.com\"}"
}
],
"order": [
"657318a8-70a5-065d-e9c5-1b7fac76bda7"
],
"timestamp": 1489131187724
}
Where "rawModeData": "{\"email\":\"abc@tudip.com\"}" is the BODY Part of the request.
How to make Above POSTMAN api (Above json is an Export of POSTMAN api call) call in ROKU ?.
7 REPLIES 7
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017
07:06 AM
Re: How to pass request with body part in HTTP POST method api request ?
Have you tried PostFromString() https://sdkdocs.roku.com/display/sdkdoc/ifUrlTransfer#ifUrlTransfer-AsyncPostFromString(requestasStr... ?
aspiring
ankitgaur
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2017
02:17 AM
Re: How to pass request with body part in HTTP POST method api request ?
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2017
07:26 PM
Re: How to pass request with body part in HTTP POST method api request ?
"ankitgaur" wrote:
We are making following API Call in Postman successfully...
i have no idea what "Postman" is - nor do i need to know more about it^. Can you send your data successfully using cURL? If yes, post here the command line that works - though i suspect figuring out how to send it with curl will help you figure out yourself how to send it from Roku.
(^) i looked on wikipedia and for me not having an article makes it "not significant enough". yes, i also noticed existence of "getpostman.com" website which seems full of itself enough not to have an "About" page
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2017
11:37 PM
Re: How to pass request with body part in HTTP POST method api request ?
"ankitgaur" wrote:
We are confused about What should be the Request in the PostFromString() function. Any Solution with an example will be very helpful.
So, Could you Please provide an Example for this Scenario.
The 'request' parameter is the query string, the exact string you'd send after the "?" if you were doing a GET request. The Roku OS internally converts the query string parameters into "body parts".
You must also ensure that the query parameters are url-encoded, if necessary, e.g. using ifUrTransfer.Escape()
E.g.:
ut = CreateObject("roUrlTransfer")
ut.SetUrl("http://myserver.com/myscript.php")
...
queryString = ut.Escape(stuff) + "&" + ut.Escape(username) + "&" + ut.Escape(password)
ut.AsyncPostFromString(queryString)
...
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2017
02:44 PM
Re: How to pass request with body part in HTTP POST method api request ?
"belltown" wrote:
The 'request' parameter is the query string, the exact string you'd send after the "?" if you were doing a GET request. The Roku OS internally converts the query string parameters into "body parts". ...
That's not quite true - in the sense that it's a perfectly valid http having a POST that has both a "?" query string and a body at the same time. We recently looked into that on account of PHP muddying the waters with its method names. On the particular case your advise seems correct though
ankitgaur
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2017
11:44 PM
Re: How to pass request with body part in HTTP POST method api request ?
"EnTerr" wrote:"belltown" wrote:
The 'request' parameter is the query string, the exact string you'd send after the "?" if you were doing a GET request. The Roku OS internally converts the query string parameters into "body parts". ...
That's not quite true - in the sense that it's a perfectly valid http having a POST that has both a "?" query string and a body at the same time. We recently looked into that on account of PHP muddying the waters with its method names. On the particular case your advise seems correct though
Hi EnTerr,
Following is the working CURL Command line URL for making API call
curl -X POST --data "email=abc@tudip.com" http://ec2-54-244-62-69.us-west-2.compu ... ord/reset/
Please provide way how to call above curl url in ROKU ?
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2017
03:28 PM
Re: How to pass request with body part in HTTP POST method api request ?
"ankitgaur" wrote:
Following is the working CURL Command line URL for making API call
curl -X POST --data "email=abc@tudip.com" http://ec2-54-244-62-69.us-west-2.compu ... ord/reset/
Please provide way how to call above curl url in ROKU ?
Ok, so it's sent application/x-www-form-urlencoded in the body. Just do what @belltown said