0

File Transfer Api

Hi

How can I get relay token which is needed for file transfer api.

Thanks

by
7 Replies
  • You receive token as result from send notification.
    Check this File Transfer Management

    Thx
    ~jimmi
    0
  • Hello,

    Thank you for reaply.

    I have some confusions about file transfer api.

    1. What is ftSessionId and how can we get it.?
    2.In file name should I pass path.
    3. In file transfer how can we make file notification request?

    Stil I make request for file transfer (for sending file) but I got the following error.

    Error :-The remote server returned an error: (400) Bad Request.

    Web Request Data:-

    string sendFile_realm = "rcore1.messenger.yahooapis.com/v1/filetransfer/relay";
    string url = "http://" + sendFile_realm + "?&sid=" + sessionId + "&oauth_consumer_key=" + oauth_consumer_key

    + "&oauth_signature_method=" + oauth_signature_method + "&oauth_nonce=" + oauth_nonce + "&oauth_timestamp=" + oauth_timestamp

    + "&oauth_signature=" + oauth_signature + "&oauth_version=" + oauth_version + "&oauth_token=" + oauth_token;

    string postdata = "{\"sendAs\":\"xyz\",\"action\":\"invite\",\"ftSessionId\":\"343258889\" ,\"target\":\"abc\":[{\"files\":{\"fileName\":\"Yahoo Api\",\"fileSize\":\"100\"}}]}";
    0
  • i am getting error while doing the file transfer invite., if i can get this working, then i can proceed to the next step, of sending the file, or doing accept/decline.

    Please find the request/response that i am doing, and let me know what wrong i am doing.


    Request:

    CODE
    POST http://rcore1.messenger.yahooapis.com/v1/filetransfer/relay?oauth_consumer_key=STRIPPED&oauth_nonce=8fbeb9ab-6ab7-41a8-bf28-aab1afce02d8&oauth_signature=STRIPPED&oauth_signature_method=PLAINTEXT&oauth_timestamp=1297014473&oauth_token=A%3DGzDK662R5zvkUDRNl.ahPQASAU06xiv3hJZwuR9fXK0qpm8EfIQijoh96vsoW9NzWaN6yAXV59VhbY
    MrXKU5FKRKe3NlBuUSmQQJW6lZreEKEU2wIbmI0dFIBohlC9CEKizR7LLNaERP_S05lz_8rNhb3f.MU8i
    zNGTqmrXwkLyeCpcrcAuS_8VLa5ZETE0LbRX59zbvk2PQxmKbQVX6lAeNabw57WpkjRUkyHRXe_qIsDYF
    Naz9Ac99UCrJ2QqS85WWOBrodl6RBO2dPAeFvJyBv0NRjwGDFNUx_GC.Zo2o_Vwf4HVuly_L0e1j3Ar.2
    3zjknarcka7e9rzL0VZXqgmAH6iUszlVWH46ivsOxVHPszM7eGqpwggl6AWTqoEx9T.iO_rRnUm.fmfj0
    A_iz9bBZZqt0T1j4Drh1jugdsiwFgMi3.NRIoyotrtDqhhn2FMFcWZs04PemYDQraPszDJlfztObVWfI3
    4ytwfDJWimVg7lRnLDJKHo9M.sgzbMZ8y1QKdMwadRTj.fDVpbMSx5.2kbDqEzK_a2CdEfyKgrlIQ4mpm
    JJt3y9tKFTh3Oun3IlyIrGbQmkvUa1epboKM0qMcJQHak.GdtTLBy1vbHzxaugFy7n5wfYzfoa8PX6kwi
    kfw9IzIstAb_po93ulNlgKUD.SJ9xJ63CH395GWjch1DsYDs4qbCFdr5W2sbR_r25_LEi.kboQ8MqCh38
    vLMDYq6R0zGDVc1o.UBxBDbn5zbR.NZUYID2wKaQKEta2eJXffJClFKvp4021IlQTzJHS94K.vIkBnTQ2
    CNfQy&oauth_version=1.0&sid=v2hChWPs3RN1VPOCOv3iEZDLv3p764g5fir9EQ-- HTTP/1.1
    Content-Type: application/json; charset=utf-8
    Host: rcore1.messenger.yahooapis.com
    Content-Length: 146
    Expect: 100-continue

    {"sendAs":"my_sender_here","action":"invite","ftSessionId":"FILE-TO-TRANSFER","target":"my_target_here","files":[{"fileName":"file.xml","fileSize":65}]}



    Response:
    CODE
    HTTP/1.1 403 Forbidden
    Date: Sun, 06 Feb 2011 17:46:19 GMT
    P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
    cache-control: public,must-revalidate
    content-length: 110
    content-type: application/json;charset=utf-8
    Vary: Accept-Encoding
    Connection: close

    {"error":{"code":-1009,"detail":"Capability Check Error","description":"Capability Check Error"},"code":-1009}
    0
  • QUOTE (Mamta Yadav @ Sep 16 2010, 02:45 AM) <{POST_SNAPBACK}>
    Hello,

    Thank you for reaply.

    I have some confusions about file transfer api.

    1. What is ftSessionId and how can we get it.?
    2.In file name should I pass path.
    3. In file transfer how can we make file notification request?

    Stil I make request for file transfer (for sending file) but I got the following error.

    Error :-The remote server returned an error: (400) Bad Request.

    Web Request Data:-

    string sendFile_realm = "rcore1.messenger.yahooapis.com/v1/filetransfer/relay";
    string url = "http://" + sendFile_realm + "?&sid=" + sessionId + "&oauth_consumer_key=" + oauth_consumer_key

    + "&oauth_signature_method=" + oauth_signature_method + "&oauth_nonce=" + oauth_nonce + "&oauth_timestamp=" + oauth_timestamp

    + "&oauth_signature=" + oauth_signature + "&oauth_version=" + oauth_version + "&oauth_token=" + oauth_token;

    string postdata = "{\"sendAs\":\"xyz\",\"action\":\"invite\",\"ftSessionId\":\"343258889\" ,\"target\":\"abc\":[{\"files\":{\"fileName\":\"Yahoo Api\",\"fileSize\":\"100\"}}]}";


    1. ftSessionId: This is client generated. As per the documentation "The client-generated file transfer session ID. Generate any ASCII string for sharing this information between the two people engaged in the file transfer. This value is generated only by the client that initiates the invite action of the file transfer handshake and is then utilized by all subsequent actions of the handshake. This value needs to be unique across all file transfer invitations within a session. Maximum of 128 bytes."
    2. No, do not pass along the file path during the handshake
    3. What do you mean by file notification request?
    0
  • QUOTE (Harshil Patel @ Feb 6 2011, 09:55 AM) <{POST_SNAPBACK}>
    i am getting error while doing the file transfer invite., if i can get this working, then i can proceed to the next step, of sending the file, or doing accept/decline.

    Please find the request/response that i am doing, and let me know what wrong i am doing.


    Request:

    CODE
    POST http://rcore1.messenger.yahooapis.com/v1/filetransfer/relay?oauth_consumer_key=STRIPPED&oauth_nonce=8fbeb9ab-6ab7-41a8-bf28-aab1afce02d8&oauth_signature=STRIPPED&oauth_signature_method=PLAINTEXT&oauth_timestamp=1297014473&oauth_token=A%3DGzDK662R5zvkUDRNl.ahPQASAU06xiv3hJZwuR9fXK0qpm8EfIQijoh96vsoW9NzWaN6yAXV59VhbY
    MrXKU5FKRKe3NlBuUSmQQJW6lZreEKEU2wIbmI0dFIBohlC9CEKizR7LLNaERP_S05lz_8rNhb3f.MU8
    i
    zNGTqmrXwkLyeCpcrcAuS_8VLa5ZETE0LbRX59zbvk2PQxmKbQVX6lAeNabw57WpkjRUkyHRXe_qIsDY
    F
    Naz9Ac99UCrJ2QqS85WWOBrodl6RBO2dPAeFvJyBv0NRjwGDFNUx_GC.Zo2o_Vwf4HVuly_L0e1j3Ar.
    2
    3zjknarcka7e9rzL0VZXqgmAH6iUszlVWH46ivsOxVHPszM7eGqpwggl6AWTqoEx9T.iO_rRnUm.fmfj
    0
    A_iz9bBZZqt0T1j4Drh1jugdsiwFgMi3.NRIoyotrtDqhhn2FMFcWZs04PemYDQraPszDJlfztObVWfI
    3
    4ytwfDJWimVg7lRnLDJKHo9M.sgzbMZ8y1QKdMwadRTj.fDVpbMSx5.2kbDqEzK_a2CdEfyKgrlIQ4mp
    m
    JJt3y9tKFTh3Oun3IlyIrGbQmkvUa1epboKM0qMcJQHak.GdtTLBy1vbHzxaugFy7n5wfYzfoa8PX6kw
    i
    kfw9IzIstAb_po93ulNlgKUD.SJ9xJ63CH395GWjch1DsYDs4qbCFdr5W2sbR_r25_LEi.kboQ8MqCh3
    8
    vLMDYq6R0zGDVc1o.UBxBDbn5zbR.NZUYID2wKaQKEta2eJXffJClFKvp4021IlQTzJHS94K.vIkBnTQ
    2
    CNfQy&oauth_version=1.0&sid=v2hChWPs3RN1VPOCOv3iEZDLv3p764g5fir9EQ-- HTTP/1.1
    Content-Type: application/json; charset=utf-8
    Host: rcore1.messenger.yahooapis.com
    Content-Length: 146
    Expect: 100-continue

    {"sendAs":"my_sender_here","action":"invite","ftSessionId":"FILE-TO-TRANSFER","target":"my_target_here","files":[{"fileName":"file.xml","fileSize":65}]}



    Response:
    CODE
    HTTP/1.1 403 Forbidden
    Date: Sun, 06 Feb 2011 17:46:19 GMT
    P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
    cache-control: public,must-revalidate
    content-length: 110
    content-type: application/json;charset=utf-8
    Vary: Accept-Encoding
    Connection: close

    {"error":{"code":-1009,"detail":"Capability Check Error","description":"Capability Check Error"},"code":-1009}


    I believe this was answered in another post. Please make sure that during login you are passing the 'fileXfer' clientCapability
    0
  • QUOTE (Vivek Aggarwal @ Feb 15 2011, 01:31 PM) <{POST_SNAPBACK}>
    I believe this was answered in another post. Please make sure that during login you are passing the 'fileXfer' clientCapability






    Hello,

    I am using file transfer API in c# desktop appliaction.I did all the step which is described in API documents.After getting file receive notification, I send the actual data of the file that time [b ]Error 500 Service Error - Invalid or missing token[/b] is comes.

    code :-


    string aYahooContactID = "xyz";
    string sendFile_realm = relayIP + "/relay";
    string url = "http://" + sendFile_realm + "?&token=" + objFile.Token + "&sender=" + primaryLoginId + "&receiver=" + aYahooContactID + "&sid=" +sessionId+ "&oauth_consumer_key=" + oauth_consumer_key + "&oauth_signature_method=" + oauth_signature_method + "&oauth_nonce=" + oauth_nonce + "&oauth_timestamp=" + oauth_timestamp + "&oauth_signature=" + oauth_signature + "&oauth_version=" + oauth_version + "&oauth_token=" + oauth_token;
    byte[] fileArr = GetFileByteArray(usersFile);
    UploadFile(url, fileArr);



    private byte[] GetFileByteArray(string filename)
    {

    FileStream oFileStream = new FileStream(filename, FileMode.Open, FileAccess.Read);

    //Create a byte array of file size.
    byte[] FileByteArrayData = new byte[oFileStream.Length];

    // Read file in bytes from stream into the byte array
    oFileStream.Read(FileByteArrayData, 0, System.Convert.ToInt32(oFileStream.Length));

    // Close the File Stream
    oFileStream.Close();
    return FileByteArrayData; //return the byte data

    }

    public string UploadFile(string URL, byte[] FileData)
    {
    string Response = null;
    HttpWebRequest WebReq = null;
    HttpWebResponse WebRes = null;
    StreamReader StreamResponseReader = null;
    Stream requestStream = null;
    try
    {
    WebReq = (HttpWebRequest)WebRequest.Create(URL);
    WebReq.Method = "POST";
    WebReq.Accept = "*/*";

    // WebReq.Connection = "Close";
    WebReq.AllowAutoRedirect = false;
    // WebReq.AllowWriteStreamBuffering = true;
    WebReq.ContentType = "text/html";// "binary/octet-stream";
    WebReq.ContentLength = FileData.Length;
    WebReq.UserAgent = "Mozilla/5.0";




    requestStream = WebReq.GetRequestStream();
    requestStream.Write(FileData, 0, FileData.Length);

    requestStream.Flush();
    requestStream.Close();

    WebRes = (HttpWebResponse)WebReq.GetResponse();
    StreamResponseReader = new StreamReader(WebRes.GetResponseStream(), Encoding.UTF8);
    Response = StreamResponseReader.ReadToEnd();
    Notify();
    }
    catch (WebException ex)
    {
    MessageBox.Show(ex.Message.ToString());
    Console.WriteLine(ex.Message.ToString());
    }
    finally
    {
    if (WebReq != null)
    {
    WebReq.Abort();
    WebReq = null;
    }
    if (WebRes != null)
    {
    WebRes.Close();
    WebRes = null;
    }
    if (StreamResponseReader != null)
    {
    StreamResponseReader.Close();
    StreamResponseReader = null;
    }
    if (requestStream != null)
    {
    requestStream = null;
    }
    }


    return Response;
    }




    please guide me.
    Thanks
    0
  • from where did you get "?&token=" + objFile.Token and what is the format of postdata?
    0

Recent Posts

in Messenger IM SDK