Hello, I have a problem uploading a product image, as an attachment, for a product via the Visma.NET API. I'm using C++ with Qt, and trying to replicate the request example (written in C#) from here: https://community.visma.com/t5/Knowledge-base-in-Developers/How-to-POST-an-attachment-via-Visma-net-API-in-C/ta-p/273574 I've came with a solution like this: ...
httpRequest req;
this->initRequest(&req, "controller/api/v1/inventory/"+itemID+"/attachment");
QHttpMultiPart *multipart = req.initMultipart(QHttpMultiPart::FormDataType);
QHttpPart imagePart;
imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/octet-stream"));
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file\"; filename=\"" + fileName + "\""));
imagePart.setBody(fileData);
multipart->append(imagePart);
req.waitForData(httpRequest::POST);
... Few notes: - fileData variable in this scope is a QByteArray, containing the data of the image file. - httpRequest class is one made by me, to handle different kind of HTTP Requests. - initRequest initializes the request by adding necessary authentication headers etc. to the request. This part is confirmed working on other endpoints which work fine. The API returns with a 400 - Bad request, with response: {"ExceptionType":"IPPException","ExceptionMessage":"","ExceptionFaultCode":"5520","ExceptionMessageID":"5520_09efa0b5-ac3b-48f8-a8c7-f9095f86a746","ExceptionDetails":""} I feel like I've tried everything... Does anyone have a working, raw request they could show so I could try and mimic that?
... View more