0

In my laravel-application I want to include my google-calendar by using the Cronofy API and the package from cronofy-php.

When I try to create an event, I get the error 422 Unprocessable Entity but I don't really know why.

Here is my create/post request

$cronofy = new Cronofy\Cronofy([
    "client_id" => config('cronofy.client_id'),
    "client_secret" => config('cronofy.client_secret'),
    "access_token" => $access_token->value,
    "refresh_token" => $refresh_token->value
]);

$params = [
    'calendar_id' => (string)request()->calendar_id,
    'event_id' => (string)request()->event_id,
    'summary' => request()->summary,
    'description' => request()->description,
    'start' => request()->start,
    'end' => request()->end
  ];

$new_event = $cronofy->upsertEvent($params);

return response('event added!', $new_event);

I both tried without and with (string) on the "calendar_id" and "event_id" but with no luck.

So, what am I doing wrong?

ST80
  • 3,565
  • 16
  • 64
  • 124

1 Answers1

2

There is more information on the reason for the 422 available to you in one of two ways.

  1. The response body will contact a JSON object describing all of the errors that are preventing the request from being processed. See error docs
  2. In the Cronofy Developer Dashboard you can see a full log of your API requests along with the same details of any errors.

This should help you understand which parameter value is causing the issue. The create and update event docs will give you guidance on allowed values and formats.

If you need further assistance you can also raise a ticket with our support team from the developer dashboard.

adambird
  • 183
  • 8
  • Ah ok nice! Was not aware of that :-) Now it works - even though its not syncing :-/ – ST80 Jan 29 '21 at 13:56