Jump to content

Rest API error TITLE_CONTENT_REQUIRED


Recommended Posts

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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...