AI Zone Admin Forum Add your forum
POST request
 
 

Service Endpoint (GET): http://localhost:8090/emp/emp_details/lee.gomes@gmail.com/

$$url = ^”\“http://localhost:8090/emp/emp_details/$name\”“
$$user_agent = ^“myemail@hotmail.com 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": "lee.gomes@gmail.com"}

 

 

 

 
  [ # 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 = ^“myemail@hotmail.com User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)”
$header = ^” ~Accept: application/json “
$_json = ^’ {"email": "lee.gomes@gmail.com"}’
$_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