Creating or update articles via API

For Joomla! 4.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
User avatar
Dangerous Boy
Joomla! Explorer
Joomla! Explorer
Posts: 302
Joined: Mon Dec 26, 2005 6:25 pm
Location: Home

Creating or update articles via API

Post by Dangerous Boy » Wed Aug 17, 2022 6:46 am

The flow is very simple, first we check the category exist, if not then create the category, then create the article, if the category already exist then check if the article exist, if not then create the article, if the article exist then update, simple, isn't it...

for creating the article, I'm sending all the columns use in #__content even so, the API is telling me that a Field category is missing!

Code: Select all

{
	"sts": false,
	"ms": {
		"errors": [
			{
				"title": "Field required: Title\nField required: Category"
			}
		]
	}
}
Host: .com/api/v1/content/articles
Method: POST
Type: json
I'm sending all columns even some custom columns, I'm sending, title, alias, catid, language, params, intro text, full text, custom col... what am I missing?
Nothing for the moment....

MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 329
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: Creating or update articles via API

Post by MarkRS » Thu Aug 18, 2022 10:31 am

Is there a reason you aren't using the "add", "edit", or "delete" routes (HTTP Request methods POST, PATCH or DELETE).

If you did J! would do all the work for you, wouldn't it?
It's a community, the more we all contribute, the better it will be.

User avatar
Dangerous Boy
Joomla! Explorer
Joomla! Explorer
Posts: 302
Joined: Mon Dec 26, 2005 6:25 pm
Location: Home

Re: Creating or update articles via API

Post by Dangerous Boy » Thu Aug 18, 2022 1:43 pm

MarkRS wrote:
Thu Aug 18, 2022 10:31 am
Is there a reason you aren't using the "add", "edit", or "delete" routes (HTTP Request methods POST, PATCH or DELETE).

If you did J! would do all the work for you, wouldn't it?
if I'm to use routes(edit, add, delete) then why having an API in the first place...
Nothing for the moment....

MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 329
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: Creating or update articles via API

Post by MarkRS » Thu Aug 18, 2022 3:44 pm

Err, sorry? I'm talking about using the API to do those things.
It's a community, the more we all contribute, the better it will be.

User avatar
Dangerous Boy
Joomla! Explorer
Joomla! Explorer
Posts: 302
Joined: Mon Dec 26, 2005 6:25 pm
Location: Home

Re: Creating or update articles via API

Post by Dangerous Boy » Thu Aug 18, 2022 4:00 pm

MarkRS wrote:
Thu Aug 18, 2022 3:44 pm
Err, sorry? I'm talking about using the API to do those things.
Then, yes, I'm using what an API allows, POST, GET, DESTROY, PATCH,DELETE... for joomla POST and PATCH uses the same method POST just different header, one is POST the other PATCH for updates... for creating an article you just the basics, title, alias, catid, for patch you send the ID, and whatever cols needs to be updated... in my case for creating I'm sending all the cols needed and some extras, for the update just what needed to be update, yet it ask for the title and category fields...
Nothing for the moment....

MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 329
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: Creating or update articles via API

Post by MarkRS » Thu Aug 18, 2022 5:15 pm

An example of one of your API calls would be helpful.
It's a community, the more we all contribute, the better it will be.


Locked

Return to “Joomla! 4.x Coding”