In case someone else has the same issue, the C# API client doesn't allow to pass an object with relationships
in it.
I had to extract the code needed to perform a manual REST call:
public static async Task<bool> MoveItemToFolderAsync(
this IItemsApi api, string projectId, string itemId, string folderId
) {
dynamic postBody = 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(postBody);
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;
}