Wednesday, April 8, 2020

REST based WEB Service. Using the Note field Correctly.


Hi Everyone,


Here is a tutorial on how to set/update the note field for records.

Setting a note value
To set a note value by the contract-based REST API, do the following:
  1. Retrieve the record in question
    1. Set your contract-based REST API request with the following settings:
      • HTTP method: GET
      • URL: https://<entity>/Default/<endpoint version>/<endpoint name>/<record name>
      • No parameters for request
      • Headers:
        • Accept -> application/json
        • Content-Type -> application/json
    2. Send the request. The response contains 200 OK status. The body of the response includes the list of fields of the record in JSON format. The following is an example
    3. {
      "id":"e72ca73d-ffcf-4b96-a07b-54988f9cd632",
      "rowNumber":1,
      "note":"",
      "CountNbr":{
      "value":"FCN000021"
      },
      "Details":[...],
      "custom":{},
      "files":[]
      }
  2. Save the request
  3. Update the note field
    1. Set your contract-based REST API request with the following settings:
      • HTTP method: PUT
      • URL: https://<entity>/Default/<endpoint version>/<endpoint name>/<top-level record name>
      • No parameters for request
      • Headers:
        • Accept -> application/json
        • Content-Type -> application/json
      • Body of the request (where NOTECONTENT should be the note):
      • {
        "id":"e72ca73d-ffcf-4b96-a07b-54988f9cd632",
        "note":"NOTECONTENT",
        }
        OR
        {
        "CountNbr":{
        "value":"FCN000021"
        },
        "note":"NOTECONTENT",
        }
    2. Send the request. If the request is successful, the response contains the 200 OK status code and includes the list of updated records in JSON format. The following is an example
    3. {
      "id":"e72ca73d-ffcf-4b96-a07b-54988f9cd632",
      "rowNumber":1,
      "note":"NOTECONTENT",
      "CountNbr":{
      "value":"FCN000021"
      },
      "Details":[...],
      "custom":{},
      "files":[]
      }
Important information to remember

  • Make sure to always specify the note parameter to the note value, even when it is not being changed, as otherwise the note will be set to a empty string. This goes for all PUT requests


No comments:

Post a Comment