Hello, I’m having a bit of an issue with uploading an image to an existing album in SmugMug website. I already authenticated the application and the user (myself) and got the perma access token and secret. However, when sending an HTTP Request to the endpoint https://upload.smugmug.com/, it is failing with a response error saying {"stat":"fail","method":"smugmug.images.upload","code":64,"message":"unknown file type"}
The issue seems to be with the inability of sending the actual image data. In their official documentation which can be found here, there is no clear indication if their API should accept raw binary data for the image or a base64 encoded data. I tried both in the Body but they always failed with the same error message above.
Ex: Assigning ImageBinary = String.Join("", ImageBytes.Select(Function(b) Convert.ToString(b, 2).PadLeft(8, "0"c)))
then passing the value in the Body. And also tried Convert.ToBase64String(ImageBytes)
I also tried different Body Types such as Binary, image/jpg, application/json, application/octet-stream but none of them work. Please note that I do not intend to upload files from local PC but rather from reading the image bytes from URLs and then sending that data in the Body of the request. I already am saving the image binary data in a variable called ImageBytes which is a byte array.
this is completely irrelevant to what I’m trying to do here.
You wanted binary body format right?
If not try with attachment directly if that works
Cheers
Analyze the HTTP request details (URL, Headers and Body) using Fiddler Classic | Original Web Capturing Tool for Windows while you are using Postman or other internal tool for which you can capture the traffic.
Then, you need to analyze the request which you are building in UiPath Studio → analyze again the HTTP Request in Fiddler → both requests needs to be identical. If they are not, fix the request in UiPath Studio.
If you cannot perform the exact request using the HTTP Request activity in UiPath Studio, use a custom Invoke Code activity for VB.Net or C#.
At the moment, I’m downloading the image and reuploading it by attaching the file path to the request and sending it, though this is a bit slower compared to directly reading the bytes and uploading it, but its fine. its just the passing of the ImageBytes which is wrong. The invoke code could perhaps work. thanks anyways.
Few checks you could do from your side
- Ensure Correct Content-Type Header: The
Content-Type
header should be set to the appropriate MIME type of the image you are uploading. For example, if you are uploading a JPEG image, the header should beContent-Type: image/jpeg
.
Use Multipart Form Data: SmugMug’s API typically expects the image to be uploaded as part of a multipart/form-data request. Here is an example of how you can structure your HTTP request:
POST https://upload.smugmug.com/
Authorization: OAuth oauth_consumer_key="your_consumer_key", oauth_token="your_token", oauth_signature_method="HMAC-SHA1", oauth_timestamp="timestamp", oauth_nonce="nonce", oauth_version="1.0", oauth_signature="signature"
Content-Type: multipart/form-data; boundary=boundary
--boundary
Content-Disposition: form-data; name="file"; filename="your_image.jpg"
Content-Type: image/jpeg
[binary data of the image]
--boundary-