Post

2 followers Follow
0
Avatar

Create Item with picture with Ruby SDK

I want to create Item which has "picture" field, of type embed. 

My code:

module Podio

class MyItem < Podio::Item
APP_ID = 123456

def self.create_from_model(my_item)
   self.create(APP_ID, { external_id:my_item.id, :fields => fields_from_model(my_item) })
end

private

def self.fields_from_model(my_item)
{
:'title' =>my_item.name,
:'picture' => {
:'file' => file_id(open(my_item.picture.url))
}
}
end

def self.file_id(file)
   Podio::FileAttachment.upload(file, "example.jpg").file_id
end
end
end

I get the following error:

 

Podio::BadRequestError: {"error_parameters"=>{}, "error_detail"=>nil, "error_propagate"=>false, "request"=>{"url"=>"http://api.podio.com/item/app/12345/", "query_string"=>"", "method"=>"POST"}, "error_description"=>"Must specify either 'embed' or 'url'", "error"=>"invalid_value"}

What's the correct way to create Item with file attached?

 

heyjobs-api-user

Please sign in to leave a comment.

1 comment

0
Avatar

Hey heyjobs,

I can see you already have url of the picture that needs to be embedded.

You can provide :url => URL instead of :file =>, f.ex"

Podio::Item.create(
APP_ID,
:fields =>
{
:title => "Sample Title",
:picture => {
:url => "http://media.oregonlive.com/pets_impact/photo/10098525-large.jpg"
}
}
)
Jakob Pułczyński 0 votes