0

Failure in SendMessage

Hi,

I am trying to call the SendMessage method, however documentation is very vague about just what the right parameters are.
I am getting
{"result":null,"error":{"code":"Client.InputInvalid","message":"Error: missing required message","detail":null}}

My code is (which sets the parameters):
CODE
                $msg = new stdClass;
$msg->message = new stdClass;
$msg->message->subject = $subject;
$msg->message->to = new stdClass;
$msg->message->to->email = $email;
$msg->message->from = new stdClass;
$msg->message->from->email = $email;
$msg->message->simplebody = new stdClass;
$msg->message->simplebody->html = $message;
$msg->message->simplebody->text = $message;
echo $ymc->SendMessage($msg, $oaToken);


Any help would be highly appreciated!
Thanks!

by
5 Replies
  • Hi,

    Can you please var_dump your request? Looking at the message there is something in your request which is not being set properly.

    Try this


    CODE
                    $msg = new stdClass();
    $msg->message = new stdClass();
    $msg->message->subject = $subject;
    $msg->message->to->name = "toemail";
    $msg->message->to->email = $email;
    $msg->message->from->name = "test";
    $msg->message->from->email = $email;
    $msg->message->simplebody = new stdClass();
    $msg->message->simplebody->html = $message;
    $msg->message->simplebody->text = $message;

    echo $ymc->SendMessage($msg, $oaToken)


    --R


    QUOTE (Dixal Patel @ Jun 28 2010, 03:09 PM) <{POST_SNAPBACK}>
    Hi,

    I am trying to call the SendMessage method, however documentation is very vague about just what the right parameters are.
    I am getting
    {"result":null,"error":{"code":"Client.InputInvalid","message":"Error: missing required message","detail":null}}

    My code is (which sets the parameters):
    CODE
                    $msg = new stdClass;
    $msg->message = new stdClass;
    $msg->message->subject = $subject;
    $msg->message->to = new stdClass;
    $msg->message->to->email = $email;
    $msg->message->from = new stdClass;
    $msg->message->from->email = $email;
    $msg->message->simplebody = new stdClass;
    $msg->message->simplebody->html = $message;
    $msg->message->simplebody->text = $message;
    echo $ymc->SendMessage($msg, $oaToken);


    Any help would be highly appreciated!
    Thanks!
    0
  • Thanks for helping.

    I am still getting the same thing.

    This is the params structure passed to the API call:
    CODE
    {"method":"SendMessage","params":{"message":{"subject":"testing t","to":{"name":"toemail","email":"danilovich.b@gmail.com"},"from":{"name":"test","email":"danilovich.b@gmail.com"},"simplebody":{"html":"here you go<\/a> ttb","text":"here you go<\/a> ttb"}}}}


    These are the headers:
    CODE
    Authorization: OAuth realm="yahooapis.com",oauth_nonce="fcf57f92e53450cd7b3f53af17c8b055",oauth_timestamp="1277833039",oauth_version="1.0",oauth_signature_method="HMAC-SHA1",oauth_consumer_key="dj0yJmk9akZQUFRZdlVBM3lGJmQ9WVdrOU5reEtjVE5ZTkhVbWNHbzlNQS0tJnM9Y29uc3VtZXJz
    ZWNyZXQmeD05NQ--",oauth_token="A%3DHuz1oI3dlwDCck2h6g8ykKSjOi7ILOBpvAgQnCPEzgVE_Hk4hxng_ivZs8JIxiY2XKVrgHCIDnbezV
    zRzI41.qwZCReX1WAaUKNhrdOY1rYauo8DWuVhw_Iuo_0m2sQPY3hCBMUd76ty9_sklrG.MsjfD61LszB
    1q4a.mnuH6NdRUuHu0t3EPjTFMYUiXiGMUW4TnKf5pc5r9oWHtoB7Xd3zuN7jAWU_tC45Wr7OWNPQCCqX
    LHfpo3V8qlxMMb5ylaXJfPvoaG4VYZslX.HR_M29kMdcMvmGtASL_m0fKbGksjjOJn31nXCCu5xNfNpZT
    X4pwRd4GCWBbo_6pLEHB98tGbF.R9gCBIuPr1zRCNUbUoVymBrEIs3YZHxWtY57z2Kyd_jy42E7C4rfdh
    2h0qSJ_H1Lvz3qgGhXpLcIDtBJFiCd9vVymN76SsL.guDaNv_FYiUf5uEBK.0b2MNDB3VXPtAtcdnnZn9
    tOmOkW4baOwvqfB6eL4pCJX4_LGNGWfa9ZkRNDFurpZDpGsLzcqC95loRyd0cA1gWhdPNAPm78ZjE4IMJ
    zNJlOKPoXSEMToMkL4BNHiHlI3Gz7Wxvq9pnD22tn1OpaSW94j1aEm4huPFj6LOSfQ5.UasLJf8ZofGBY
    0FuwRhQyJk9AXYA5GASQFf.AGibEOEa9zXGsvc6KdD9.nxTkRj1Ek79SReoo_9lFDcRCXOZtmjB0YBU4P
    9VUJeUihk3Pth97lxYKVWu4KraoRR3hnMqdg--",oauth_signature="Zgx%2Bcgpc%2BsfH9BNRmicvQYsU0Rg%3D"


    Also, note the example here: http://developer.yahoo.com/mail/docs/user_...endMessage.html.
    It has very little parameters in the request.
    0
  • Hi,

    The request should be json encoded before you send it to the server. Can you please confirm this? also can you tell me what is your endpoint?

    For e.g.
    {"method":"SendMessage","params":[{"message":{"subject":"hi","from":{"email":"test1@test.com"},"to":[{"email":"test2@test.com"}],"body":{"data":"Test number is XYV0993","type":"text","subtype":"plain","charset":"us-ascii"}}}]}

    Compare the above with your request and you would no the difference. If it still doesn't work then please do paste the entire request and also tell me the response you are getting. Thanks

    --R

    QUOTE (Dixal Patel @ Jun 29 2010, 09:40 AM) <{POST_SNAPBACK}>
    Thanks for helping.

    I am still getting the same thing.

    This is the params structure passed to the API call:
    CODE
    {"method":"SendMessage","params":{"message":{"subject":"testing t","to":{"name":"toemail","email":"danilovich.b@gmail.com"},"from":{"name":"test","email":"danilovich.b@gmail.com"},"simplebody":{"html":"here you go<\/a> ttb","text":"here you go<\/a> ttb"}}}}


    These are the headers:
    CODE
    Authorization: OAuth realm="yahooapis.com",oauth_nonce="fcf57f92e53450cd7b3f53af17c8b055",oauth_timestamp="1277833039",oauth_version="1.0",oauth_signature_method="HMAC-SHA1",oauth_consumer_key="dj0yJmk9akZQUFRZdlVBM3lGJmQ9WVdrOU5reEtjVE5ZTkhVbWNHbzlNQS0tJnM9Y29uc3VtZXJz
    ZWNyZXQmeD05NQ--",oauth_token="A%3DHuz1oI3dlwDCck2h6g8ykKSjOi7ILOBpvAgQnCPEzgVE_Hk4hxng_ivZs8JIxiY2XKVrgHCIDnbezV
    zRzI41.qwZCReX1WAaUKNhrdOY1rYauo8DWuVhw_Iuo_0m2sQPY3hCBMUd76ty9_sklrG.MsjfD61Lsz
    B
    1q4a.mnuH6NdRUuHu0t3EPjTFMYUiXiGMUW4TnKf5pc5r9oWHtoB7Xd3zuN7jAWU_tC45Wr7OWNPQCCq
    X
    LHfpo3V8qlxMMb5ylaXJfPvoaG4VYZslX.HR_M29kMdcMvmGtASL_m0fKbGksjjOJn31nXCCu5xNfNpZ
    T
    X4pwRd4GCWBbo_6pLEHB98tGbF.R9gCBIuPr1zRCNUbUoVymBrEIs3YZHxWtY57z2Kyd_jy42E7C4rfd
    h
    2h0qSJ_H1Lvz3qgGhXpLcIDtBJFiCd9vVymN76SsL.guDaNv_FYiUf5uEBK.0b2MNDB3VXPtAtcdnnZn
    9
    tOmOkW4baOwvqfB6eL4pCJX4_LGNGWfa9ZkRNDFurpZDpGsLzcqC95loRyd0cA1gWhdPNAPm78ZjE4IM
    J
    zNJlOKPoXSEMToMkL4BNHiHlI3Gz7Wxvq9pnD22tn1OpaSW94j1aEm4huPFj6LOSfQ5.UasLJf8ZofGB
    Y
    0FuwRhQyJk9AXYA5GASQFf.AGibEOEa9zXGsvc6KdD9.nxTkRj1Ek79SReoo_9lFDcRCXOZtmjB0YBU4
    P
    9VUJeUihk3Pth97lxYKVWu4KraoRR3hnMqdg--",oauth_signature="Zgx%2Bcgpc%2BsfH9BNRmicvQYsU0Rg%3D"


    Also, note the example here: http://developer.yahoo.com/mail/docs/user_...endMessage.html.
    It has very little parameters in the request.
    0
  • I am having the *exact* same problem.

    I have a PHP script:

    script.php

    /////////////////////////////////////////////////////////////////
    // Messages
    // //////////////////////////////////////////////////////////////
    $msg_email_d = sql_request('SELECT msg_email FROM accounts WHERE id = '.$aid);
    $msg_email = $message[0]['msg_email'];

    $savecopy = FALSE;
    $subject = 'Check this out';
    /*
    SimpleMessageBody Class

    text Text of the message body
    html HTML version of the message body.
    attachment In the form "upload://id", where id is returned by the Upload Attachment method
    */
    $simplebody = new stdclass();
    $simplebody->text = $msg_email;
    $simplebody->html = $msg_email;
    ?>



    Widget



    /*
    ComposeMessage Class

    subject Subject for message
    inreplyto In reply to this message, if any.
    from Source email {ComposeAddress}
    to Destination email {ComposeAddress}
    replyto Reply to email {ComposeAddress}
    cc {ComposeAddress}
    bcc {ComposeAddress}
    body {ComposeMessagePart}
    meta Meta data
    simplebody {SimpleMessageBody}

    */
    foreach ($contacts as $contact)
    {
    /*
    ComposeAddress Class

    name Email address or Yahooid

    */
    $address = new stdclass();
    $address->name = $contact;

    $message = new stdclass();
    $message->subject = $subject;
    $message->simplebody = $simplebody;
    $message->to = $address;

    $session->SendMessage($message, $savecopy);
    $batchcall = new stdclass();
    $batchcall->SendMessage = new stdclass();
    $batchexecute = new stdclass();
    $batchexecute->call = $batchcall;
    $batchresponse = $session->BatchExecute($batchexecute);
    echo 'Sending message to ' . $address->name . ' ('. var_dump($batchresponse) . ")
    \n";

    }




    As you can see, I go through my contact list and in my test I have one e-mail sent. The reponse I get back is:
    object(stdClass)#14 (1)
    {
    ["response"]=> array(1)
    {
    [0]=> object(stdClass)#15 (2)
    {
    ["ErrorResponse"]=> object(stdClass)#16 (3)
    {
    ["code"]=> string(24) "ymws:Client.InputInvalid"
    ["string"]=> string(31) "Error: missing required message"
    ["detail"]=> NULL

    }
    ["success"]=> bool(false)

    }

    }

    }


    ..apparently the exact same response... what could be going on wrong here?
    0
  • up, same error here

    0

Recent Posts

in Yahoo! Mail Web Services API