Upload with API v2 error
quiks
Registered Users Posts: 19 Big grins
Hi,
I'm writing an Android app to upload images to SmugMug. I'm using V2 of the API.
I've used a 3rd party OAuth library (oauth.signpost) for OAuth. This seems to work well since I was able to get a token and make a call (https://api.smugmug.com/api/v2!authuser).
For the upload, I've tried a lot of things, all of them leading to :
{"stat":"fail","method":"smugmug.images.upload","code":5,"message":"system error"}
I've looked at the Upload logs (https://secure.smugmug.com/homepage/uploadlog.mg). Nothing mentioned. If I skip one of the required headers, then I see something. If I don't attach the file to the POST, I also see something.
But if I do everything correctly (headers + data), I just get the error, nothing in the logs...
In order for me to double check what I really send, I generated a Java Servlet deployed under Tomcat a list all headers that I receive. I also write the data that I get from the post.
The file is correct (JPG file). The headers I receive in the servlet are the following:
Header [x-smug-albumuri]=[/api/v2/album/n-Zj5m8]
Header [x-smug-responsetype]=[JSON]
Header [x-smug-version]=[v2]
Header [authorization]=[OAuth oauth_consumer_key="Ruar6x4fqR6EI9nTslrlvbrihYWSwHoJ", oauth_nonce="5689814974954522603", oauth_signature="HlHt3m8fO2sg9NbWYp6M9JTDSuk%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1470297133", oauth_token="MY_AUTH_TOKEN", oauth_token_secret="MY_TOKEN_SECRET", oauth_version="1.0"]
Header [content-length]=[125800]
Header [host]=[10.0.2.2:8080]
Header [connection]=[Keep-Alive]
Header [user-agent]=[Apache-HttpClient/UNAVAILABLE (java 1.4)]
I also checked that the permission of the app is correct in SmugMug (Access=Full, Permissions=Add).
The App is "SmugLoad" under my account.
Any idea? Thanks a lot!
Greg.
I'm writing an Android app to upload images to SmugMug. I'm using V2 of the API.
I've used a 3rd party OAuth library (oauth.signpost) for OAuth. This seems to work well since I was able to get a token and make a call (https://api.smugmug.com/api/v2!authuser).
For the upload, I've tried a lot of things, all of them leading to :
{"stat":"fail","method":"smugmug.images.upload","code":5,"message":"system error"}
I've looked at the Upload logs (https://secure.smugmug.com/homepage/uploadlog.mg). Nothing mentioned. If I skip one of the required headers, then I see something. If I don't attach the file to the POST, I also see something.
But if I do everything correctly (headers + data), I just get the error, nothing in the logs...
In order for me to double check what I really send, I generated a Java Servlet deployed under Tomcat a list all headers that I receive. I also write the data that I get from the post.
The file is correct (JPG file). The headers I receive in the servlet are the following:
Header [x-smug-albumuri]=[/api/v2/album/n-Zj5m8]
Header [x-smug-responsetype]=[JSON]
Header [x-smug-version]=[v2]
Header [authorization]=[OAuth oauth_consumer_key="Ruar6x4fqR6EI9nTslrlvbrihYWSwHoJ", oauth_nonce="5689814974954522603", oauth_signature="HlHt3m8fO2sg9NbWYp6M9JTDSuk%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1470297133", oauth_token="MY_AUTH_TOKEN", oauth_token_secret="MY_TOKEN_SECRET", oauth_version="1.0"]
Header [content-length]=[125800]
Header [host]=[10.0.2.2:8080]
Header [connection]=[Keep-Alive]
Header [user-agent]=[Apache-HttpClient/UNAVAILABLE (java 1.4)]
I also checked that the permission of the app is correct in SmugMug (Access=Full, Permissions=Add).
The App is "SmugLoad" under my account.
Any idea? Thanks a lot!
Greg.
0
Comments
Hi Greg,
What endpoint/url are you POSTing to?
I don't see a "Content-Type" header, which if you're doing a raw POST of just the image binary should be 'image/jpeg'.
The album uri you're using is actually a node uri (the n-prefix identifies it). You want the Album Uri, not the node uri. (yes its confusing and silly and I do apologize).
Give those a shot and let us know if you're able to get things working.
Sorry for the really late response, you were right, the album URI was wrong, I changed it for the real one (/api/v2/album/JwkrMr), it's working now clapclap
THANK YOU THANK YOU THANK YOU.