I've trying to connect to your API via our Android app. OAuth and REST works. However, I'm having issues with posting a new image block into a workbook.My request is:Content-Type: image/jpeg
Content-Length: 12345 (complete size of string, including pre-fix "data:image/jpeg;base64,")data:image/jpeg;base64,<BASE64DATA>
The error I'm getting is:
Error attaching a photo. This doesn't necessarily mean that there's a problem. The phone will resend it.
I've tried to change the value of Content-Type into "image/jpeg", and produced the same error.
My oAuth customer key is: fd341b6afa414ae19ebe8bab2822ae01
Any sample code is appreciated. I use the oAuth Scribe Library for Java. Below you'll find my test code.
OAuthService service = new ServiceBuilder()
.provider(SpringpadApi.class)
.apiKey("fd341b6afa414ae19ebe8bab2822ae01")
.apiSecret("XXXXX")
//.debug()
.debugStream(System.out)
.build();
Token accessToken = new Token("ed368e29841e33706479ebb6cd221823",
"XXX");
try {
File file = new File("/Users/taoufik/Desktop/logo.jpg");
byte [] fileData = new byte[(int)file.length()];
DataInputStream dis = new DataInputStream((new FileInputStream(file)));
dis.readFully(fileData);
dis.close();
OAuthRequest request = new OAuthRequest(
Verb.POST,
request.addHeader("Content-Type", "image/jpeg");
String data = "data:image/jpeg;base64," + new Base64().encodeToString(fileData);
request.addPayload(data);
service.signRequest(accessToken, request);
Response response = request.send();
String content = response.getBody();
System.out.println(content);
} catch (IOException e) {
e.printStackTrace();
}
hi Chuck,Thanks for the reply.I've just tried again now: Mon, 04 Mar 2013 16:14 UTC+0 (London, UK).I've also enabled wireshark, this is the data over the wire. I've replaced all the privacy sensitive info with XXXXXXX (7 times X):POST /api/users/me/blocks/2d35d337-22cc-429c-b910-86f34be00a83/photos?encoding=base64 HTTP/1.1Authorization: OAuth oauth_signature="XXXXXXX", oauth_version="1.0", oauth_nonce="1509043094", oauth_signature_method="HMAC-SHA1", oauth_consumer_key="XXXXXXX", oauth_token="XXXXXXX", oauth_timestamp="1362413680"X-Spring-Client: XXXXXXXAccept: application/javascriptContent-Type: application/octet-streamUser-Agent: Java/1.6.0_41Host: springpad.comConnection: closeContent-Length: 22195data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QaWRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAALAAAAcgEyAAIAAAAUAAAAfodpAAQAAAABAAAAkgAAANQAAABIAAAAAQAAAEgAAAABR0lNUCAyLjguMAAAMjAxMjoxMDoxMiAyMzowN....... (omitted the rest)Date: Mon, 04 Mar 2013 16:14:42 GMTServer: Apache-Coyote/1.1Expires: Sun, 03 Mar 2013 16:14:42 GMTPragma: no-cacheCache-Control: no-cache, no-store, must-revalidateContent-Type: application/javascript;charset=UTF-8Content-Language: en-USContent-Length: 138Via: 1.1 springpad.comX-Robots-Tag: noindex, nofollow, noarchiveVary: Accept-EncodingVia: 1.1 springpad.comConnection: close{"status":"error","message":"Error attaching a photo. This doesn't necessarily mean that there's a problem. The phone will resend it."}Thanks for your help!Taoufik
--
You received this message because you are subscribed to the Google Groups "Springpad Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to springpaddev...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.