Solved Error during multipart upload using Qt
-
@daljit97
in this example you never add the created http-part to the multi-part object -
@raven-worx said:
@daljit97
in this example you never add the created http-part to the multi-part objectYeah, sorry I accidentally deleted it while deleting a comment.
-
@daljit97
no need to set the header again on the request. This is already implied by using QMultiPartHttp class.Beside that, what is the server you are uploading to?
-
@raven-worx the server is https://upload.pushbullet.com
-
@daljit97
so you receive the bad request error already from the "request itself" or in the Pushbullet's JSON response? -
@raven-worx The error is simple a reading of reply->errorString()
-
@daljit97
ok, also post the contents of the reply (even if it has an error set).
Maybe the pushbullet server has some more hints there.Also isn't there any authentication required by the server?
-
@raven-worx said:
@daljit97
ok, also post the contents of the reply (even if it has an error set).
Maybe the pushbullet server has some more hints there.Also isn't there any authentication required by the server?
This is the reply from the server
{\"error\":{\"code\":\"invalid_request\",\"type\":\"invalid_request\",\"message\":\"No file included in request.\",\"cat\":\"(=\xEF\xBC\xB4\xE3\x82\xA7\xEF\xBC\xB4=)\"},\"error_code\":\"invalid_request\"}'
As for the authentication it shouldn't be required but I performed a check with a token and it still gives the same error.
-
@daljit97
there you have the message "No file included in request". This should already help alot and means that the error is Pushbullet specific and actually has nothing todo with Qt itself.I think you are just missing a parameter which is expected by the pushbullet server. So you need to research how the request is expected.
Pushbullet docs say:
Copy of all the parameters from the data object in the response to the upload request. In addition to that, the file should be uploaded as the parameter file.
I think i've also read that you need to add the "file_type" and "file_name" parameters to the request. Maybe this already solves it.
Next time please provide all the relevant info from the beginning.
The type of the server is an essential information during upload ;) -
@raven-worx Alright thank you, I'll keep that in mind. However, I do not understand why it gives that error, since I am attaching the file in the request.
-
@daljit97
(i modified my answer while you responded in the meantime) -
@raven-worx Thank you very much for your help. I have added the missing "--" at the end of the request (I forgot to clean the project, that's probably why it didn't work before). I did not use the data parameter since it was deprecated by Pushbullet.