Foxpro / Support API / Create Sharing Agreement
Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcCreated_at
LOCAL lcId
LOCAL lcName
LOCAL lcPartner_name
LOCAL lcRemote_subdomain
LOCAL lcStatus
LOCAL lcV_Type
LOCAL lcV_Url
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
loHttp.BasicAuth = 1
loHttp.Login = "login"
loHttp.Password = "password"
loHttp.SetRequestHeader("Accept","application/json")
loResp = loHttp.QuickRequest("POST","https://example.zendesk.com/api/v2/sharing_agreements")
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
CANCEL
ENDIF
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
? "Response Header:"
? loResp.Header
? "Failed."
RELEASE loResp
RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp
CANCEL
ENDIF
RELEASE loResp
* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)
* {
* "sharing_agreement": {
* "created_at": "<dateTime>",
* "id": "<integer>",
* "name": "<string>",
* "partner_name": "<string>",
* "remote_subdomain": "<string>",
* "status": "<string>",
* "type": "<string>",
* "url": "<string>"
* }
* }
* Sample code for parsing the JSON response...
* Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
lcCreated_at = loJResp.StringOf("sharing_agreement.created_at")
lcId = loJResp.StringOf("sharing_agreement.id")
lcName = loJResp.StringOf("sharing_agreement.name")
lcPartner_name = loJResp.StringOf("sharing_agreement.partner_name")
lcRemote_subdomain = loJResp.StringOf("sharing_agreement.remote_subdomain")
lcStatus = loJResp.StringOf("sharing_agreement.status")
lcV_Type = loJResp.StringOf("sharing_agreement.type")
lcV_Url = loJResp.StringOf("sharing_agreement.url")
RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp
Curl Command
curl -u login:password -X POST
-H "Accept: application/json"
https://example.zendesk.com/api/v2/sharing_agreements
Postman Collection Item JSON
{
"name": "Create Sharing Agreement",
"request": {
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/sharing_agreements",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"sharing_agreements"
]
},
"description": "#### Allowed For\n\n* Admins\n"
},
"response": [
{
"name": "Created response",
"originalRequest": {
"method": "POST",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/sharing_agreements",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"sharing_agreements"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"sharing_agreement\": {\n \"created_at\": \"<dateTime>\",\n \"id\": \"<integer>\",\n \"name\": \"<string>\",\n \"partner_name\": \"<string>\",\n \"remote_subdomain\": \"<string>\",\n \"status\": \"<string>\",\n \"type\": \"<string>\",\n \"url\": \"<string>\"\n }\n}"
}
]
}