Unsupported content with type: multipart/form-data
This simple calendar_events_watch request does not run correctly:
GoogleApi.Calendar.V3.Connection.new(access_token)
|> GoogleApi.Calendar.V3.Api.Events.calendar_events_watch("primary", [resource: %{...}])
{:error,
%Tesla.Env{
...
body: "{\n \"error\": {\n \"errors\": [\n {\n \"domain\": \"global\",\n \"reason\": \"badContent\",\n \"message\": \"Unsupported content with type: multipart/form-data; boundary=194fad99068751d50d113fb07433c3bf\"\n }\n ],\n \"code\": 400,\n \"message\": \"Unsupported content with type: multipart/form-data; boundary=194fad99068751d50d113fb07433c3bf\"\n }\n}\n",
}
}
Is there something wrong?
I had the same issue in GoogleApi.Admin.Directory_v1.Api.Users.directory_users_watch
I suspect google api doesn't support multipart/form-data in OAuth2 api
refs: https://stackoverflow.com/a/37587304/9721470
I'm encountering the same issue with GoogleApi.Drive.V3.Api.Files.drive_files_watch. Did either of you find a solution @Ephemera @vip30 ?
I'm encountering the same issue with
GoogleApi.Drive.V3.Api.Files.drive_files_watch. Did either of you find a solution @Ephemera @vip30 ?
I gave up the client in directory watch and implemented it by Httpoison Would like to see if there is any others work around
I think I'll go ahead and do that too. Spent the last few hours fiddling. Do you have a sample of the Poison code you wrote for that request?
I think I'll go ahead and do that too. Spent the last few hours fiddling. Do you have a sample of the Poison code you wrote for that request?
The code is something like that
token = Auth.get_token("https://www.googleapis.com/auth/admin.directory.user", :admin)
case request(
:post,
%{
domain: domain,
event: event
},
"https://www.googleapis.com/admin/directory/v1/users/watch",
channel,
token.token
) do
{:ok, response} ->
Poison.decode!(response.body, as: %GoogleChannel{})
{:error, info} ->
Logger.info("error in watch_user #{inspect(info)}")
nil
end
defp request(method, params, url, body, token) do
HTTPoison.request(%HTTPoison.Request{
method: method,
params: params,
url: url,
body: Poison.encode!(body),
headers: [{"authorization", "Bearer #{token}"}, {"content-type", "application/json"}]
})
end
I solved it the same way using HTTPoison.