HTTP Request Headers / Form Fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2015 08:32 AM
Details : I have been asked to replace a PHP script file that launches a REST POST message with an equivalent file in javascript on ServiceNow.
I have constructed a UI page which is based on the following wiki page: http://wiki.servicenow.com/index.php?title=Table_API_JavaScript_Examples#POST
My challenge comes with variable substitution.
When the UI page is called on ServiceNow, it's done via a HTTP POST on another server.
That server submits the HTTP POST with all the variables needed to renter the REST POST message.
I'm having difficulty determining how to include the variables from the HTTP POST in the REST POST on the ServiceNow UI page.
Your help would be greatly appreciated
var requestBody = '{"u_chat_transcript": "this is a test","u_agent_id":"bobama"}';
var client=new XMLHttpRequest();
client.open("POST","/api/now/table/u_8x8_stage_ws");
client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json');
client.onreadystatechange = function(){
if(this.readyState = this.DONE){
document.getElementById("response").innerHTML=this.status + this.response;
}};
client.send(requestBody);
The example above works with static values for the request, however I need to get variables that have been presented to the server via an HTTP POST.
In the .asp world you would say request.form('variablename').... can someone offer an explanation how this is done on serviceNow?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2015 09:57 AM
Hi Mike,
I have done similar task using java with table API.
Please look into this post https://community.servicenow.com/thread/171612
The same can be done using PHP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2015 11:36 AM
Akash,
I'm not seeing how this relates.
I need to get to the fields posted on a ServiceNow UI Page using traditional HTTP POST.
Did I miss something ?
Thanks,
Mike Reaves

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2015 12:24 AM
Ohh! I see.
You want to update UI Page using HTTP POST.
Could you please send me your PHP script or can I do this in Java or any other web technology.
Thanks,
Akash Rajput
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 01:06 PM
Mike - did you figure out how to do this? I need to do something similar and can't find a good reference anywhere. I have to believe this is possible.