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 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.