1

I want to integrate with a 3rd party Rest API. Now the API have the following definition for a Create operation:-

> URL :-  https://<IP address>:7272/restapi/json/v1/resources?AUTHTOKEN
> HTTP METHOD: POST
> 
> Sample Requests
> 
> curl -X POST -k -H "Content-Type: text/json" 
> 'https://IP:7272/restapi/json/v1/resources?AUTHTOKEN=***'
> -d  'INPUT_DATA={"operation":{"Details":{"RESOURCENAME":"Windows  Server","ACCOUNTNAME":"Administrator","RESOURCETYPE":"Windows","PASSWORD"
> :"Test123#@!","NOTES":"Testing 
> API","RESOURCEURL":"http://windowsserver/adminconsole","RESOURCECUSTOMFIEL
> D":[{"CUSTOMLABEL":"Secure Resource","CUSTOMVALUE":"YES"}]}}}'

so can anyone advice how I can post JSON to the API from my action method? I usually use WebClient.DownloadString to receive json from the API,, but not sure how I can send json object ?

1 Answers1

1

On how to send a POST request, look here for example: HTTP request with post

For creating the JSON data, you could use a library like the excellent Json.NET http://www.newtonsoft.com/json or build the string on your own.

Community
  • 1
  • 1
aschoenebeck
  • 439
  • 7
  • 9