Data at Your Fingertips: Explore Our New Reporting and Statistical Capabilities By Ryan Ashbrook Tuesday at 01:29 PM
virap1 Posted April 7 Share Posted April 7 I must be missing something because I can't upload a picture along with the database record. This code works as expected, but fails to add the picture to the featured image field. Any ideas what I am doing wrong? Thank you. $zimg="https://content.invisioncic.com/e322713/pages_media/3_1.jpg"; $image = array(); $image['article']=file_get_contents($zimg); $fields = array(); $fields['18']="title test"; $fields['19']="desc test"; $fields['image']=$image; $data = array( "title" => "title test1", "content" => "content test1", "status" => "published", // Or "draft" "category" => 19, "author" => 191972, "fields" => $fields, ); $communityUrl = 'https://www.communityUrl.com/'; $apiKey = 'apiKey'; $curl = curl_init( $communityUrl . 'api/cms/records/7' ); curl_setopt_array( $curl, array( CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => "{$apiKey}:", CURLOPT_USERAGENT => "MyUserAgent/1.0", CURLOPT_POST => 1, CURLOPT_POSTFIELDS => http_build_query($data), ) ); $response = curl_exec( $curl ); Link to comment Share on other sites More sharing options...
Daniel F Posted April 7 Share Posted April 7 Have you tried record_image as $fields array key instead of only image? Link to comment Share on other sites More sharing options...
virap1 Posted April 7 Author Share Posted April 7 Thank you @Daniel F, Changing $fields['image']=$image to $fields['record_image']=$image does not appear to work too. Link to comment Share on other sites More sharing options...
virap1 Posted April 8 Author Share Posted April 8 Does anyone know if there is a solution? Link to comment Share on other sites More sharing options...
virap1 Posted April 8 Author Share Posted April 8 If currently there is no way to upload an image to record_image, can IPB please consider adding this to the API? Also, if the image is already in the media can we update the url of the record's image and set it to the existing file within a media folder? If that also is impossible, is there a way to create a custom field and set that as the default image field for the database so the image will appear within the record, meta data, feeds etc. and replace the default record image? Thank you. Link to comment Share on other sites More sharing options...
Daniel F Posted April 10 Share Posted April 10 It should be possible to set the image via the API. I‘ll take a look at this tomorrow. Link to comment Share on other sites More sharing options...
virap1 Posted April 12 Author Share Posted April 12 Thank you @Daniel F. Were you able to check on this? Link to comment Share on other sites More sharing options...
Daniel F Posted April 13 Share Posted April 13 Thank you for bringing this issue to our attention! I can confirm this should be further reviewed and I have logged an internal bug report for our development team to investigate and address as necessary, in a future maintenance release. Link to comment Share on other sites More sharing options...
Recommended Posts