You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the Box Developer Forums and my issue isn't already reported (or if it has been reported, I have attached a link to it, for reference).
Here is my code snippet to update doctypes which I am passing as array
templateKey: "arms", requestBody: Array.AsReadOnly(new[] { new UpdateFolderMetadataByIdRequestBody() { Op = UpdateFolderMetadataByIdRequestBodyOpField.Replace, Path = "/doctypes", Value = "[\"Asbuilt\", \"RW Plat\"]" } }));
I had contacted Box Platform Support Team and they responded that client (Box .NET SDK) should not have \ prefixed.
So I am suspecting some bug where this information is passed to API endpoint in .NET SDK code.
Thanks for the additional information. I can confirm that, on our end, the request body which is being evaluated in the api call is
[{"op":"replace","path":"/doctypes","value":"["Asbuilt","RW Plat"]"}]
In my own testing in Postman PUT request on a multiselect metadata instance without backspaces received a successful 200 response:
Whereas when backslashes were introduced to the value like so:
curl --location --request PUT 'https://api.box.com/2.0/files/1715987212712/metadata/enterprise/multiselect'
--header 'Content-Type: application/json-patch+json'
--header 'Authorization: ••••••'
--data '[
{
"op": "add",
"path": "/dwarfs",
"value":["doc"]
}
]'
A 400 invalid parameter error is received. You may likewise isolate the issue to the particular C# code in question by taking similar steps.
Steps to Reproduce
Create a template 'arms' with multiselect field type let's say doctypes with acceptable values as doc1,doct2 and doc3
Run following code
UpdateFolderMetadataByIdScope.Enterprise, templateKey: "arms", requestBody: Array.AsReadOnly(new[] { new UpdateFolderMetadataByIdRequestBody() { Op = UpdateFolderMetadataByIdRequestBodyOpField.Replace, Path = "/doctypes", Value = "[\"doc1\", \"doc2\"]" } }));
Expected Behavior
SDK should handle serialization of array items and remove backward slash before making call to API endpoint.
Error Message, Including Stack Trace
System.AggregateException: One or more errors occurred. ({"message":"Encountered invalid value for template field key=doctypes with id=3de83589-70dc-414a-92e1-7aa48d1e77be","code":"bad_request","request_id":"j8bccbhw8f93hatm"})
---> Box.Sdk.Gen.BoxApiException: {"message":"Encountered invalid value for template field key=doctypes with id=3de83589-70dc-414a-92e1-7aa48d1e77be","code":"bad_request","request_id":"j8bccbhw8f93hatm"}
at Box.Sdk.Gen.Internal.HttpClientAdapter.FetchAsync(FetchOptions options)
at Box.Sdk.Gen.Managers.FolderMetadataManager.UpdateFolderMetadataByIdAsync(String folderId, UpdateFolderMetadataByIdScope scope, String templateKey, IReadOnlyList1 requestBody, UpdateFolderMetadataByIdHeaders headers, Nullable1 cancellationToken)
at UpdateEFL.Program.ExecuteMainAsync(AppConfig appConfig) in C:\gisu-repos\UpdateEFL2016\UpdateEFL\Program.cs:line 163
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
Versions Used
.NET SDK: 1.5.0
.NET: 8.0
The text was updated successfully, but these errors were encountered:
It looks like issue lies within specification. In case of multiselect, array of values should be send (as seen in your cURL). Spec describes this field as string https://developer.box.com/reference/put-folders-id-metadata-id-id/#param-%253Citem%253E-value which is incorrect. Due to the fact that we generate models based on spec, it's affecting this operation. I raised an issue internally.
Description of the Issue
Here is my code snippet to update doctypes which I am passing as array
I had contacted Box Platform Support Team and they responded that client (Box .NET SDK) should not have \ prefixed.
So I am suspecting some bug where this information is passed to API endpoint in .NET SDK code.
Thanks for the additional information. I can confirm that, on our end, the request body which is being evaluated in the api call is
[{"op":"replace","path":"/doctypes","value":"["Asbuilt","RW Plat"]"}]
In my own testing in Postman PUT request on a multiselect metadata instance without backspaces received a successful 200 response:
curl --location --request PUT 'https://api.box.com/2.0/files/1715987212712/metadata/enterprise/multiselect'
--header 'Content-Type: application/json-patch+json'
--header 'Authorization: ••••••'
--data '[
{
"op": "add",
"path": "/dwarfs",
"value":["doc"]
}
]'
Whereas when backslashes were introduced to the value like so:
curl --location --request PUT 'https://api.box.com/2.0/files/1715987212712/metadata/enterprise/multiselect'
--header 'Content-Type: application/json-patch+json'
--header 'Authorization: ••••••'
--data '[
{
"op": "add",
"path": "/dwarfs",
"value":["doc"]
}
]'
A 400 invalid parameter error is received. You may likewise isolate the issue to the particular C# code in question by taking similar steps.
Steps to Reproduce
Expected Behavior
SDK should handle serialization of array items and remove backward slash before making call to API endpoint.
Error Message, Including Stack Trace
System.AggregateException: One or more errors occurred. ({"message":"Encountered invalid value for template field key=doctypes with id=3de83589-70dc-414a-92e1-7aa48d1e77be","code":"bad_request","request_id":"j8bccbhw8f93hatm"})
---> Box.Sdk.Gen.BoxApiException: {"message":"Encountered invalid value for template field key=doctypes with id=3de83589-70dc-414a-92e1-7aa48d1e77be","code":"bad_request","request_id":"j8bccbhw8f93hatm"}
at Box.Sdk.Gen.Internal.HttpClientAdapter.FetchAsync(FetchOptions options)
at Box.Sdk.Gen.Managers.FolderMetadataManager.UpdateFolderMetadataByIdAsync(String folderId, UpdateFolderMetadataByIdScope scope, String templateKey, IReadOnlyList
1 requestBody, UpdateFolderMetadataByIdHeaders headers, Nullable
1 cancellationToken)at UpdateEFL.Program.ExecuteMainAsync(AppConfig appConfig) in C:\gisu-repos\UpdateEFL2016\UpdateEFL\Program.cs:line 163
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
Versions Used
.NET SDK: 1.5.0
.NET: 8.0
The text was updated successfully, but these errors were encountered: