Add relationships data to PatchItemData
According to this discussion in the Autodesk forums and this SO response by Augusto , the PATCH item endpoint can accept the relationships data, so that files can be moved from a directory to another.
Unfortunately the PatchItemData doesn't have a Relationships property, so it's not possible to use this feature.
Can we have this added?
Also, what's the point of going through all the type checking if the body argument of PatchItemWithHttpInfo(Async) has to be a PatchItem object? By the way, there's also redundant null type checking all over the place (if body is null an exception is raised at the beginning of the methods, no need to re-check if is not null in the following lines...)
I tried to pass a dynamic object as the body parameter, but obviously it complains because there's no overload of the method that accepts this type.
I'm appalled that such a basic feature is not 1) documented in the API 2) Implemented in this client.
I thought Autodesk would have some more resources to spend on their projects... Not even an "aknowledge" or "wontfix" in almost 5 moths.
FYI, I resolved by manually creating the request:
public static class Extensions {
public static async Task<bool> MoveItemToFolder(this IItemsApi api, string projectId, string itemId, string folderId) {
dynamic body = new {
jsonapi = new { version = "1.0" },
data = new {
type = "items",
id = itemId,
relationships = new {
parent = new {
data = new {
type = "folders",
id = folderId
}
}
}
}
};
string jsonBody = JsonConvert.SerializeObject(body);
var request = new RestRequest($"/data/v1/projects/{projectId}/items/{itemId}", Method.Patch);
request.AddBody(jsonBody, "application/vnd.api+json");
request.AddHeader ("Authorization", $"Bearer {api.Configuration.AccessToken}");
request.AddHeader ("Content-Type", "application/vnd.api+json");
var client = api.Configuration.ApiClient.RestClient;
var response = await client.ExecuteAsync(request);
int statusCode = (int)response.StatusCode;
return statusCode == 200;
}
}