Jump to content

Featured Replies

Posted

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 );

 

  • 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.

Have you also set the content?

The error means that either the title or the content field isn't set.

  • 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 by virap1

  • 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.
 

  • Author

I don't see anything on how to send the data for the Record Image? Just as image => image url ?

Recently Browsing 0

  • No registered users viewing this page.