Chilkat Online Tools

Swift3 / Microsoft Graph / Create ediscoveryReviewSetQuery

Back to Collection Items

func chilkatTest() {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!
    var success: Bool

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "displayName": "Microsoft Graph Query",
    //   "contentQuery": "(Author=\"edison\")"
    // }

    let json = CkoJsonObject()!
    json.update("displayName", value: "Microsoft Graph Query")
    json.update("contentQuery", value: "(Author=\"edison\")")

    // Adds the "Authorization: Bearer <access_token>" header.
    http.authToken = "<access_token>"

    var resp: CkoHttpResponse? = http.postJson3("https://graph.microsoft.com/v1.0/security/cases/ediscoveryCases/{{ediscoveryCaseId}}/reviewSets/{{ediscoveryReviewSetId}}/queries", contentType: "application/json", json: json)
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    print("\(resp!.statusCode.intValue)")
    print("\(resp!.bodyStr!)")
    resp = nil

}

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-d '{
    "displayName": "Microsoft Graph Query",
    "contentQuery": "(Author=\"edison\")"
}'
https://graph.microsoft.com/v1.0/security/cases/ediscoveryCases/{{ediscoveryCaseId}}/reviewSets/{{ediscoveryReviewSetId}}/queries

Postman Collection Item JSON

{
  "name": "Create ediscoveryReviewSetQuery",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "var json = JSON.parse(responseBody);",
          "postman.setEnvironmentVariable(\"ediscoveryReviewSetQueryId\", json.id);"
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"displayName\": \"Microsoft Graph Query\",\n    \"contentQuery\": \"(Author=\\\"edison\\\")\"\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "https://graph.microsoft.com/v1.0/security/cases/ediscoveryCases/{{ediscoveryCaseId}}/reviewSets/{{ediscoveryReviewSetId}}/queries",
      "protocol": "https",
      "host": [
        "graph",
        "microsoft",
        "com"
      ],
      "path": [
        "v1.0",
        "security",
        "cases",
        "ediscoveryCases",
        "{{ediscoveryCaseId}}",
        "reviewSets",
        "{{ediscoveryReviewSetId}}",
        "queries"
      ]
    }
  },
  "response": [
  ]
}