0

I hope to find some help to diving deeper into Podiokit, the ObjC-API to Podio. I try to set a link-field's value to a URL. My first simple try looked like this:

NSDictionary *embedAttributes = [NSDictionary dictionaryWithObject: @"http://www.google.com" forKey: @"url"];            
PKTEmbed *embed = [[PKTEmbed alloc] initWithDictionary: embedAttributes];
item[@"linkfield"] = embed;

I found an example using PHP but had no luck to transform it into Objective-C:

$attributes = array( 'url' => 'http://www.infranet.com' );
$embed = PodioEmbed::create( $attributes );
$attribute['embed']['embed\_id'] = $embed->embed\_id;
$attribute['file']['file\_id'] = $embed->files[0]->file\_id;
$this->orgItem->field('organizationlink')->set\_value($attribute);

Maybe someone knows how to get it right, would be fine :-)

[Edit] The PodioKit-Manual just says:

PKTEmbed *link = ...;
item[@"link"] = link;

[Edit 2] The error occurs when I try to save the item. The log says:

Error: Saving file Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: Ungültige Anforderung (400)" UserInfo=0x600000c7ee80 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x6000008358e0> { URL: https://api.podio.com/item/app/_xxxx_/ } { status code: 400, headers {
"Content-Length" = 263;
"Content-Type" = "application/json; charset=utf-8";
Date = "Sat, 27 Sep 2014 19:16:22 GMT";
Server = nginx;
"X-Podio-Request-Id" = yqyl6yku;
"X-Rate-Limit-Limit" = 250;
"X-Rate-Limit-Remaining" = 248;
} }, NSLocalizedDescription=Request failed: Ungültige Anforderung (400), NSErrorFailingURLKey=https://api.podio.com/item/app/_xxxx_/}

Thanks, Michael / Hamburg

ShooTerKo
  • 2,242
  • 1
  • 13
  • 18

1 Answers1

1

Sebastian at Podio here. You need to first create the PKTEmbed object server side, then use it as the value of the item field. So you would use:

PKTItem *item = ...;
[[PKTEmbed createEmbedForURLString:@"https://www.google.com"] onSuccess:^(PKTEmbed *embed) {
  item[@"link-field"] = embed;
} onError:^(NSError *error) {
  // Handle error
}];

The server will assign you an embedID and generate a thumbnail for you etc. I will look into adding the ability to simply provide a URL string directly, as I agree that makes a lot of sense.

Hope that helps!

  • Wow, I did nearly a copy/paste of your code and it works perfectly! Greetings from Germany/Hamburg! – ShooTerKo Oct 05 '14 at 20:41
  • I have now added the ability to give an `NSString` with the URL directly on object creation. Like `item["link-field"] = @"https://www.google.com"` You just need to run `pod update` to get the latest changes from the master branch. Hope that helps! – Sebastian Rehnby Oct 14 '14 at 14:30
  • That's a good and clear improvement! I think it will help a lot when setting a link field's value, it's really more straight foreward :-) But the other way works, too! – ShooTerKo Oct 15 '14 at 08:23