1

Upload Attachment

Hi
Everywhere it's being said that we have to use Oauth and BBAuth is depricated.
I hope upload attachment is supported in oauth.
I tried uploading using the post parameters given in the documentation.
I got this error with 501 status code:

<?xml version='1.0' encoding='UTF-8'?>
<yahoo:error xmlns:yahoo='http://yahooapis.com/v1/base.rng' xml:lang='en-US'>
<yahoo:description>application/x-www-form-urlencoded not supported with OAuth</yahoo:description>
</yahoo:error>
<!-- web53207.mail.re2.yahoo.com uncompressed Thu Apr 8 23:58:01 PDT 2010 -->

May i know the reason behind it. Kindly tell me how to proceed?

Thanks

by
13 Replies
  • Hi Kaku,

    Yes we do support Upload and Download APIs in OAuth based access. Can you send your POST request headers and params and give a brief on how you are trying to achieve this? Also we recently updated our guide for Upload, Download and SendMessage APIs. Can you please confirm if you referring to the latest doc?
    Thanks.

    --R

    QUOTE (kaku @ Apr 8 2010, 11:11 PM) <{POST_SNAPBACK}>
    Hi
    Everywhere it's being said that we have to use Oauth and BBAuth is depricated.
    I hope upload attachment is supported in oauth.
    I tried uploading using the post parameters given in the documentation.
    I got this error with 501 status code:

    <?xml version='1.0' encoding='UTF-8'?>
    <yahoo:error xmlns:yahoo='http://yahooapis.com/v1/base.rng' xml:lang='en-US'>
    <yahoo:description>application/x-www-form-urlencoded not supported with OAuth</yahoo:description>
    </yahoo:error>
    <!-- web53207.mail.re2.yahoo.com uncompressed Thu Apr 8 23:58:01 PDT 2010 -->

    May i know the reason behind it. Kindly tell me how to proceed?

    Thanks
    0
  • POST http://mail.yahooapis.com/ya/upload
    authorization: OAuth realm="yahooapis.com",oauth_nonce="1270894703203",oauth_consumer_key="[apiKey]",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1270894703",oauth_version="1.0",oauth_signature="5cTjeOr3msW7QBsCRr%2F6ZQb9t%2FI%3D",oauth_session_handle="[sessionHandle]",oauth_token="[token]"
    content-length: 39

    user-agent: Jakarta Commons-HttpClient/3.1
    content-type: application/x-www-form-urlencoded

    POST PARAMETERS
    output=json
    uploadfile=C:/blow.txt

    I tried again by changing the content type to "text/plain". Though it didn't gave the previous error, it now gave a different error:
    <?xml version="1.0" encoding="UTF-8"?>
    <Error>uploadFileSizeError</Error>
    <!-- web53206.mail.re2.yahoo.com uncompressed/chunked Sat Apr 10 03:30:53 PDT 2010 -->

    how could it be uploadFileSize error, it's a damn small file.
    Please tell what's the error in the request.
    Thanks
    0
  • H,

    Can you confirm if you are passing the encoded contents of the file as part of the POST request?

    Ideally external libraries if used takes care of forming this but if you are doing this manually then try setting the boundary and pass the base64 encoded file contents along with the request as shown below.

    For e.g.
    POST /ya/upload
    Content-Length: 32731
    Content-Type: multipart/form-data; boundary=---------------------------7da34b1d80888
    Cookie: B=27l1d2t534pjd&b=4&d=J0o0cAxpYEKrWNxzrCEOkvwSdFWXs8UBh_d.KQ--&s=ug&i=wgmj2zTKifIKcTQIdcFh;

    ^@<F9><BC>KD6^N^@<DC>^E^@^@<EA>^E^@^@^@^^^K<D5>F^Z^@^R<F2>l*^@^H^@E^@^E<DC>90@^@?^F,^Wb<89>ESC{C<C3>^O^NP^P^@P<F4><B5><D3>sH<AD>0|<80>^P<82>^X$:^@^@^A^A^H
    <89><98>x^G<F3><C4><91><CE>-----------------------------7da34b1d80888
    Content-Disposition: form-data; name="_charset_"

    utf-8
    -----------------------------7da34b1d80888
    Content-Disposition: form-data; name="uploadfile"; filename="C:\Users\Ma\<C3><A0>.xls"
    Content-Type: application/vnd.ms-excel

    <D0><CF>^Q<E0><A1><B1>^Z<E1>^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@>^@^C^@<FE><FF> ^@^F^@^@^@^@^@^@^@^@^@^@^@^A^@^@^@<^@^@^@^@^@^@^@^@^P^@^@<FE><FF><FF><FF>^@^@^@^@<FE><FF><FF><FF>^@^@^@^@;^@^@^@<FF><FF><FF>F><FF><FF> ^P^@^@^F^E^@<AF>^X<CD>^G<C9><C0>^@^@^F^A^@^@<E1>^@^B^@<B0>^D<C1>^@^B^@^@^@<E2>^@^@^@\^@p^@^E^@^@Ma


    --R

    QUOTE (kaku @ Apr 10 2010, 02:34 AM) <{POST_SNAPBACK}>
    POST http://mail.yahooapis.com/ya/upload
    authorization: OAuth realm="yahooapis.com",oauth_nonce="1270894703203",oauth_consumer_key="[apiKey]",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1270894703",oauth_version="1.0",oauth_signature="5cTjeOr3msW7QBsCRr%2F6ZQb9t%2FI%3D",oauth_session_handle="[sessionHandle]",oauth_token="[token]"
    content-length: 39

    user-agent: Jakarta Commons-HttpClient/3.1
    content-type: application/x-www-form-urlencoded

    POST PARAMETERS
    output=json
    uploadfile=C:/blow.txt

    I tried again by changing the content type to "text/plain". Though it didn't gave the previous error, it now gave a different error:
    <?xml version="1.0" encoding="UTF-8"?>
    <Error>uploadFileSizeError</Error>
    <!-- web53206.mail.re2.yahoo.com uncompressed/chunked Sat Apr 10 03:30:53 PDT 2010 -->

    how could it be uploadFileSize error, it's a damn small file.
    Please tell what's the error in the request.
    Thanks
    0
  • Hi
    Thanks a ton for your support.
    It worked.
    THANKS AGAIN
    kaku
    0
  • Hi
    I was able to do the upload Attachment, but when i'm sending it during "Send Message" method, it's giving the following error:

    {
    "result":null,
    "error":{
    "code":"Client.InputInvalid",
    "message":"Submitted ComposeAttachment is of incorrect type: string",
    "detail":null
    }
    }

    Along with "html": "htmlBody", i'm passing the attachment as follows in the SimpleMessageBody tag:
    "attachment":"upload://[idRetrieved from UploadAttachment]"

    Do i have to give the attachment id in some other tag or what? Kindly tell how to provide the attachment ID
    Thanks
    0
  • Hi,

    Looking at the error message I guess the request is being sent as String and not JSON. Can you confirm if its being sent as JSON.

    --R

    QUOTE (kaku @ Apr 12 2010, 11:18 PM) <{POST_SNAPBACK}>
    Hi
    I was able to do the upload Attachment, but when i'm sending it during "Send Message" method, it's giving the following error:

    {
    "result":null,
    "error":{
    "code":"Client.InputInvalid",
    "message":"Submitted ComposeAttachment is of incorrect type: string",
    "detail":null
    }
    }

    Along with "html": "htmlBody", i'm passing the attachment as follows in the SimpleMessageBody tag:
    "attachment":"upload://[idRetrieved from UploadAttachment]"

    Do i have to give the attachment id in some other tag or what? Kindly tell how to provide the attachment ID
    Thanks
    0
  • Hi
    I'm sending JSON only.
    here's my request BODY. Kindly check it out.
    {
    "params":
    [
    {
    "message":
    {
    "to":[{"email":"someone@yahoo.com"}],
    "simplebody":
    {
    "text":"Please co-operate with the tests :P--R
    0
  • Hi,

    Try giving attachment like below

    CODE
           "simplebody": {
    "text": "SendMessage with message with one attachment FILENAME",
    "attachment": [
    {
    "attachment": "upload:\\\/\\\/XXXXXXXXXX"
    }
    ]
    }

    Guess this should work. For complete sample on SendMessage request refer http://github.com/ramiyer/YahooMailApiSample. (Readme file has json request example). Thanks

    --R


    QUOTE (kaku @ Apr 13 2010, 11:44 PM) <{POST_SNAPBACK}>
    Hi
    I'm sending JSON only.
    here's my request BODY. Kindly check it out.
    {
    "params":
    [
    {
    "message":
    {
    "to":[{"email":"someone@yahoo.com"}],
    "simplebody":
    {
    "text":"Please co-operate with the tests :P}
    0
  • Hi
    This worked. Their was not an error of upload slashes. The error was that we have to pass attachments ids as an JSON Array and then have to include it under JSON object again named as attachment.
    These things are hard to guess. I'll again say that please include JSON examples in your documentations.
    THANKS
    0
  • Yes the JSON snippet above was given to address your issue and it had nothing to do with slashes. I absolutely understand its difficult to guess such things and hence the github link which I had posted before has examples which are not in the documents. Do let us know if you need anything further. Happy coding.

    --R

    QUOTE (kaku @ Apr 14 2010, 02:26 AM) <{POST_SNAPBACK}>
    Hi
    This worked. Their was not an error of upload slashes. The error was that we have to pass attachments ids as an JSON Array and then have to include it under JSON object again named as attachment.
    These things are hard to guess. I'll again say that please include JSON examples in your documentations.
    THANKS
    0
    • H
    • Mar 1, 2012
    Hi everybody, i&#39;ve been fighting with the upload method for some days and I cant make it work!<br><br>If i send a POST request to&nbsp;http://mail.yahooapis.com/ya/upload, it returns me a 404 error &quot;Sorry, the page you requested was not found.&quot;<br><br><div>POST http://mail.yahooapis.com/ya/upload HTTP/1.1<div>Content-Type: multipart/form-data; boundary=----------------------------8cec5b6a93c6334<div>Host: mail.yahooapis.com<div>Content-Length: 13384<br><br><div>------------------------------8cec5b6a93c6334<div>Content-Disposition: form-data; name=&quot;uploadfile&quot;;filename =&quot;4017(B).png.png&quot;<div>Content-Type: image/png<div>�PNG.... (...more file content data....)<br>------------------------------8cec5b6a93c6334<br><br>any idea?</div></div></div></div></div></div></div></div>
    0
    • Sep 2, 2012
    Hello,
    could you please post a complete request example of upload attachment :)
    please.

    QUOTE(kaku @ 12 Apr 2010 11:18 PM)
    Hi
    Thanks a ton for your support.
    It worked.
    THANKS AGAIN
    kaku
    0
  • I too am having challenges with upload attachments. I actually get a 404 error, which is very strange. Here is what I am posting:

     POST http://mail.yahooapis.com/ya/upload
    Headers:
      Authorization:    [myoauth data]
      Content-Type: multipart/form-data; boundary=4e8db4f2ae40
    
    --4e8db4f2ae40
    Content-Disposition: form-data; name="uploadfile"; filename="c:\test.txt"
    Content-Type: text/plain
    
    dGVzdGluZyAxMjM
    --4e8db4f2ae40-- 
    

    That file, test.txt just contains "testing 123" - which is base 64 encoded as the "dGVzdGluZyAxMjM" you see in the body.

    Any help is greatly appreciated

    0
  • My issue turns out to be that I was signing the request before adding the body form-data to it. I am not sure why this resulted in a 404 error, but either way it is all working now.

    0
  • Recent Posts

    in Yahoo! Mail Web Services API