Jump to content

Recommended Posts

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

 

Posted

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.

Posted (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 by virap1
Posted

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.
 

  • Recently Browsing   0 members

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