cancel
Showing results for 
Search instead for 
Did you mean: 

Bad Request on Edit Keywords

Paul_Hoecherl
Confirmed Champ
Confirmed Champ

I am trying to update a documents keywords with RestSharp using the Keyword Operations documentation here: https://sdk.onbase.com/rest/OnBase/FoundationEP3/document/programmers-guide/working-with-keywords.ht...

 

I am not able to get past a “Bad Request” error when executing the final PUT.

 

The steps in this scenario:

  • Obtain the Response.Data from the GET;

  • Change the Keyword data values for keywords of interest;

  • Serialize the changed Response.Data to JSON using:
       var putParms = JsonMs.JsonSerializer.Serialize(getResponse.Data);

  • Add the resulting JSon to a new putRequest ( a new RestRequest instance, with Method.Put) as a parameter:
      putRequest.AddParameter("application/json", putParms, ParameterType.RequestBody);

  • ­Execute the put request.

 

Am I missing anything here, perhaps something obvious?

 

Any advice appreciated!

1 ACCEPTED ANSWER

Paul_Hoecherl
Confirmed Champ
Confirmed Champ

Thanks fellas: After some additional work. I am down to a specific error:
"The Date Format for Keyword Value with Keyword Type Id: 104 is incorrect"

104 is a Date type, and the JSON string looks like this:

\"typeId\":\"104\",\"values\":[{\"value\":\"11/16/2021 12:00:00 AM\"}]

 

That is actually the current value of the Keyword, retrieved by the previous GET, and it doesn't seem to matter how I reformat the date-time (removing the time portion, changing the date format, even just setting it empty) - the PUT always fails with this error.

 

For clarity, here is the Keyword Type definition for the 104:

{
            "dataType": "Date",
            "id": "104",
            "invisible": false,
            "name": "Invoice Date",
            "systemName": "Invoice Date",
            "usedForRetrieval": true
},
 
I am not attempting to edit this DateTime with the PUT: it is unchanged.

 

Any thoughts?

 

 

UPDATE

>>>>

This keyword (104) has dataType:"Date"


Trying to set the value to "11/16/2021 12:00:00 AM\" fails because the string has a time-stamp.

 

If I strip the time-stamp off, leaving "11/16/2021", the update succeeds.

 

Lesson: Date and DateTime values are NOT coercive!

 

<<<<

View answer in original post

3 REPLIES 3

aboucher
Community Manager
Community Manager

Hi @Paul Hoecherl (ClarkPUD),

 

If no one in our community can identify what is causing your “Bad Request” error,  you can reach out to OnBase API Support. 

 

To receive direct support from the Hyland API Support team, you or a member of your organization needs to have completed the OnBase API Certification Course (OCAPI). This requirement is in place to ensure that code troubleshooting be done with a person that is familiar with the OnBase APIs. 

 

If you do not have anyone in your organization that is API Certified, then you can reach out for a Services engagement through your account manager. 

 

Thanks!

~Alan

AdamShaneHyland
Employee
Employee

Hi @Paul Hoecherl (ClarkPUD) ,

 

In order to determine the root cause, you would have to provide more information on the details of the issue.  Bad Request is a bit of a generic error message simply stating that the HTTP request you made to the Document Management REST API endpoint is a bad request.

 

You can reference the Update Keywords Request Body section of the Working with Keywords programs guide of the REST API SDK ...

 

https://sdk.onbase.com/rest/OnBase/Foundation22.1/document/programmers-guide/working-with-keywords.h...

 

If you are encountering errors, then there are two places to look for the reason.

  • Review the HTTP Response data to see if there is a message in the response body
  • Review the Hyland Diagnostics logs on the server running the ApiServer web application.  You should see an error message within the ApiServer profile. 

Take care.

Paul_Hoecherl
Confirmed Champ
Confirmed Champ

Thanks fellas: After some additional work. I am down to a specific error:
"The Date Format for Keyword Value with Keyword Type Id: 104 is incorrect"

104 is a Date type, and the JSON string looks like this:

\"typeId\":\"104\",\"values\":[{\"value\":\"11/16/2021 12:00:00 AM\"}]

 

That is actually the current value of the Keyword, retrieved by the previous GET, and it doesn't seem to matter how I reformat the date-time (removing the time portion, changing the date format, even just setting it empty) - the PUT always fails with this error.

 

For clarity, here is the Keyword Type definition for the 104:

{
            "dataType": "Date",
            "id": "104",
            "invisible": false,
            "name": "Invoice Date",
            "systemName": "Invoice Date",
            "usedForRetrieval": true
},
 
I am not attempting to edit this DateTime with the PUT: it is unchanged.

 

Any thoughts?

 

 

UPDATE

>>>>

This keyword (104) has dataType:"Date"


Trying to set the value to "11/16/2021 12:00:00 AM\" fails because the string has a time-stamp.

 

If I strip the time-stamp off, leaving "11/16/2021", the update succeeds.

 

Lesson: Date and DateTime values are NOT coercive!

 

<<<<