我正在尝试使用ConnectWise SDK在ConnectWise Manage中创建票证和产品。 我已经设法使连接正常工作,并且可以毫无问题地创建票证,但是在尝试创建产品时却始终收到“ 400-错误的请求”。
我在Visual Studio中使用C#。
有人可以告诉我我在做什么错吗?
private static async Task TestPost()
{
//Create the client
var client = getApiClient();
//Get a ticket to duplicate
var ticketsApi = new TicketsApi(client);
var getResponse = await ticketsApi.GetTicketByIdAsync(55482);
var ticket = await getResponse.GetResultAsync<Ticket>(); //I get the correct ticket here
//Create the duplicate ticket
var createResponseTicket = await ticketsApi.CreateTicketAsync(ticket); //This works without error
var newTicket = await createResponseTicket.GetResultAsync<Ticket>();
Console.WriteLine("Ticket ID: " + newTicket.Id);
//Get a product to duplicate
var productsApi = new ProductsItemApi(client);
var response = await productsApi.GetProductByIdAsync(1);
var product = await response.GetResultAsync<ProductItem>(); //I get the correct product here
//Create the duplicate product
var createResponseProduct = await productsApi.CreateProductAsync(product); //Here I get a "400 - Bad Request" error
var newProduct = await createResponseProduct.GetResultAsync<ProductItem>();
Console.WriteLine("Product ID: " + newProduct.Id);
}