AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

POST request
 
 

Service Endpoint (GET): http://localhost:8090/emp/emp_details/[email protected]/

$$url = ^”\“http://localhost:8090/emp/emp_details/$name\”“
$$user_agent = ^“[email protected] User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)”
$_tmp = ^jsonopen(transient GET $$url “” $$user_agent)
$fname = $_tmp.fname
$lname = $_tmp.lname
$phone= $_tmp.phone
Address Book : $fname $lname - $phone

How can I do a POST request for the same?
Consider the endpoint as http://localhost:8090/emp/ and input json as {"email": "[email protected]"}

 

 

 

 
  [ # 1 ]

Change GET to POST
Pass the json as a string the 4th parameter - use ^jsonwrite() if your JSON is held in a CS variable as it will handle all the escaping correctly.
Extend the headers to include “~Content-Type: application/json”

 

 
  [ # 2 ]

u: (test)  ^keep() ^repeat()
$$url = ^”\“http://localhost:8090/test/\”“
$$user_agent = ^“[email protected] User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)”
$header = ^” ~Accept: application/json “
$_json = ^’ {"email": "[email protected]"}’
$_tmp = ^jsonopen(transient POST $$url $_json $header $$user_agent)
$fname = $_tmp.fname
$lname = $_tmp.lname
$phone= $_tmp.phone
Address Book : $fname $lname - $phone

I got it implemented this way, is it the right way? Please review.

 

 
  login or register to react