Creates a new account.
curl -X POST https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/accounts \
-H "Accept: application/json" \
-H "Content-Type: application/json; charset=utf-8" \
-H "OData-MaxVersion: 4.0" \
-H "OData-Version: 4.0" \
-H "Authorization: Bearer DYNAMICS_CRM_ACCESS_TOKEN" \
-d '{
"name": "Sample Account",
"creditonhold": false,
"address1_latitude": 47.639583,
"description": "This is the description of the sample account",
"revenue": 5000000,
"accountcategorycode": 1
}'
require 'chilkat'
rest = Chilkat::CkRest.new()
# URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/accounts
bTls = true
port = 443
bAutoReconnect = true
success = rest.Connect("my-dynamics-domain.api.crm.dynamics.com",port,bTls,bAutoReconnect)
if (success != true)
print "ConnectFailReason: " + rest.get_ConnectFailReason().to_s() + "\n";
print rest.lastErrorText() + "\n";
exit
end
json = Chilkat::CkJsonObject.new()
json.UpdateString("name","Sample Account")
json.UpdateBool("creditonhold",false)
json.UpdateNumber("address1_latitude","47.639583")
json.UpdateString("description","This is the description of the sample account")
json.UpdateNumber("revenue","5000000")
json.UpdateNumber("accountcategorycode","1")
rest.AddHeader("Content-Type","application/json; charset=utf-8")
rest.AddHeader("OData-Version","4.0")
rest.AddHeader("Accept","application/json")
rest.AddHeader("OData-MaxVersion","4.0")
rest.AddHeader("Authorization","Bearer DYNAMICS_CRM_ACCESS_TOKEN")
sbRequestBody = Chilkat::CkStringBuilder.new()
json.EmitSb(sbRequestBody)
sbResponseBody = Chilkat::CkStringBuilder.new()
success = rest.FullRequestSb("POST","/api/data/v9.0/accounts",sbRequestBody,sbResponseBody)
if (success != true)
print rest.lastErrorText() + "\n";
exit
end
respStatusCode = rest.get_ResponseStatusCode()
if (respStatusCode >= 400)
print "Response Status Code = " + respStatusCode.to_s() + "\n";
print "Response Header:" + "\n";
print rest.responseHeader() + "\n";
print "Response Body:" + "\n";
print sbResponseBody.getAsString() + "\n";
exit
end