Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
virap1 Posted March 3, 2023 Posted March 3, 2023 Hello. I hope someone can help me to understand how to include a title while trying to submit a database entry using rest api. At the moment this code given an error message saying "errorMessage": "TITLE_CONTENT_REQUIRED" Thank you very much. $fields[18]="title test"; $data = array( "status" => "published", // Or "draft" "category" => 19, "author" => 191972, "fields" => $fields, ); $communityUrl = 'https://www.mydomain.com/'; $apiKey = 'my key'; $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 );
virap1 Posted March 3, 2023 Author Posted March 3, 2023 Sorry to bump this. Could someone help me solve the TITLE_CONTENT_REQUIRED error and to understand how to properly send the title and content of the database entry? Thank you.
Daniel F Posted March 3, 2023 Posted March 3, 2023 Have you also set the content? The error means that either the title or the content field isn't set.
virap1 Posted March 3, 2023 Author Posted March 3, 2023 (edited) Thank you @Daniel F. The problem is no matter how I try I can't get it to work. Setting it directly through title=> "test title" or through the $fields array does not work $fields['18']="title test"; $fields['title']="title z"; $fields['content']="content z"; $data = array( "title" => "title test1", "content" => "content test1", "status" => "published", // Or "draft" "category" => 19, "author" => 191972, "fields" => $fields, ); Edited March 3, 2023 by virap1
virap1 Posted March 3, 2023 Author Posted March 3, 2023 I accidentally figured out that adding the content like this $fields['19']="description test" solves the issue. Thank you for pointing me to the right direction.
virap1 Posted March 3, 2023 Author Posted March 3, 2023 I don't see anything on how to send the data for the Record Image? Just as image => image url ?
Recommended Posts