Kaseya Community

Using the API to send an email

This question has suggested answer(s)

Hi,

I’m trying to use the API to send an email, but I keep getting this error :

 { "ResponseCode": 4001001, "Status": "Failed", "Error": "FromAddress can't be null/empty, ToAddress can't be null, Subject can't be null, UniqueTag can't be null" }

 Only thing is all fields are not null/empty this is my payload I’m sending to the API for the request :

 {"FromAddress":"support@soso.co.za,"ToAddress":"ghansford@soso.co.za,"Subject":"Download link","Body":"https:\/\/support.soso.co.za\/dl.asp","IsBodyHtml":true,"Priority":0,"UniqueTag":"1"}

This is the PHP I use to generate the payload :

$data = json_encode(array(
"FromAddress" => $sender,
"ToAddress" => $email,
"Subject" => "Downloadlink",
"Body" => $body,
"IsBodyHtml" => true,
"Priority" => 2,
"UniqueTag" => "zwp59",

));

Does anyone have any idea as to why it keeps failing with the same message? I have tried different words and numbers in the unique tag as well as tried different numbers for the priority, but it always fails with the same error.

Also does anyone know what the priority or the uniquetag should be?

Regards, 

 

All Replies
  • Hi,

    I managed to get the email working, the issue it turns out was my headers I was missing the content-type and accept headers and it was causing it to fail :

    $headers = array (

             'Authorization : Bearer ' . $token,

             'Content-Type: application/json',

             'Accept: application/json',

                     );

    Didn't find that listed in the documentation any where.

    Regards,