Home Forums Integration Integration (Code) Open API – Update attribute of type Enum

Viewing 2 reply threads
  • Author
    Posts
    • #10605

      Hello,

      We are trying to update an enum attribute of an object.

      We have tried two ways, using an OID and the value of the enum object

      When using the OID, the update works however we get the JSON format errors in the log and 500 error response.
      When using the value, we get access denied error.

      Details of request/response below.

      Can you please provide guidance on best mechanism to be used?

      OID Method

      • First retrieve the OID by reading the desired enum object and then use to set the value

      Request:
      <pre class=”lang:java decode:true crayon-selected”>{
      “$class”: “Address”,
      “$oid”: “10B49BB34CDD1449A8842A18441316579C”,
      “countryValue”: {
      “$class”: “Country”,
      “$oid”: “4341474F42656E4853434F554E545259”
      }
      }
      Response:

      2019-06-06 13:15:04,849 ERROR [nexj.core.rpc.json.JSONHTTPServer] (ajp-nio-0.0.0.0-8009-exec-31:/nexj http:11111111 nexjsa) Error processing the JSON request (reference id omnijl)

      java.lang.NullPointerException

      at nexj.core.rpc.http.RESTHTTPServer.invoke(RESTHTTPServer.java:484)

       

       

      Value method:
      <pre class=”lang:java decode:true “>{
      “$class”: “Address”,
      “countryValue”: {
      “$class”: “Country”,
      “value”: “CAN”
      }
      }
       

       

      Response/error:

      {

      “$message”: “Access denied to an instance of class \”Country\”.”,

      “$code”: “err.runtime.access”,

      “$arguments”: [

      “Country”

      ]

      }

      0
    • #10616
      Firahs ChebboFirahs Chebbo
      Participant

      For future reference, this issue was resolved by using PUT as opposed to POST for update requests.

      0
    • #10629
      Shahzad Qureshishahzad.qureshi
      Keymaster

      For reference: https://restfulapi.net/rest-put-vs-post/

      “Generally, in practice, always use PUT for UPDATE operations. Always use POST for CREATE operations.”

      0
Viewing 2 reply threads
  • You must be logged in to reply to this topic.