Hi, i am reading the "Create Endpoint" article in the API documentation guide. I can't make the Post request work.
Could you provide a php code where i can see how to create the body for the request?
I'm using this code:
$fetch = $client->fetch($baseApiUrl . '/api/v1/sites/johndoe/pages/blogs/1/posts/', $parameters = array($json_body), 'POST', array(
"Content-Type" => "application/json",
"x-li-format" => "json"
));
I get this message: "invalid_json".
Thanks in advance!!
Official response from
submitted
Fernando, check out this PHP library.
Do you like this suggestion?
Showing 4 reactions
Sign in with
You can send us the report as a text file attachment to [email protected]
That library is the one I’m using right now.
It’s work perfect for the GET method but when i try to Create a new Post on the blog it fail.
My code:
$body = ‘{
“blog_post”: {
“name”: “You will never guess”,
“slug”: “puzzle”,
“status”: “published”,
“content_before_flip”: “<p>You will never guess what is after the flip</p>”,
“content_after_flip”: “<p>The answer is words. Words were after the flip.</p>”,
“tags”: [“funny”, “true”],
“published_at”: “2013-04-25T10:47:06-07:00”
}
}’;
$client->fetch($baseApiUrl . ‘/api/v1/sites/johndoe/pages/blogs/1/posts’, array($token), array($body), ‘POST’, array(
“Content-Type” => “application/json”,
“x-li-format” => “json”
));
I created this code reading the class library.
Now the message is: 500 Error Server
Anyone with same problem?