Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted March 3, 20231 yr 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 );
March 3, 20231 yr Author 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.
March 3, 20231 yr Have you also set the content? The error means that either the title or the content field isn't set.
March 3, 20231 yr Author 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, 20231 yr by virap1
March 3, 20231 yr Author 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.
March 3, 20231 yr Author I don't see anything on how to send the data for the Record Image? Just as image => image url ?