Guidance with Rest API
« on: November 10, 2023, 07:14:06 PM »
I'm starting to explore API's and the one that interests me most is the Osclass API.
I've installed the plugin on a test site and created my test API key for all operations, Read, Insert, Update, Delete.
Tried some simple operations like reading region and other tables successfully, i have used postman and SoapUI and also some code to perform the tests.
Now i'm trying to explore additional types, objects and actions.

One specificaly i'm trying is to insert ads, so i went to the great help page on the plugin and looked for the insert type and add action of object item.

However i'm having some difficulty as i get 500 error for this API call.
I had the must add picture plugin activated but the result is the same with it deativated.
While exploring the help on the plugin i can't find the attributes that are required, but i believe it can be explored somewhere.

Can someone guide me on how should i use the API and where can i find the attributes to get into the add action, and other actions ?

Thanks
« Last Edit: November 13, 2023, 07:00:21 PM by [email protected] »

*

MB Themes

Re: Guidance with Rest API
« Reply #1 on: November 10, 2023, 07:51:53 PM »
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Guidance with Rest API
« Reply #2 on: November 13, 2023, 07:43:21 PM »
Thanks for the link and sorry for not finding :-)
I'll follow on this to understand how i can use the API.

Re: Guidance with Rest API
« Reply #3 on: November 14, 2023, 01:35:18 AM »
The example is great and allowed me to test adding listings, thanks for that.

I now hit another problem. I added some custom fields (native osclass function, not plugin) that i use in some categories.

Can i use custom field in the API, and how ?
« Last Edit: November 14, 2023, 02:39:39 AM by [email protected] »

*

MB Themes

Re: Guidance with Rest API
« Reply #4 on: November 14, 2023, 09:50:51 AM »
Go to your search page to that category, filter by custom fields.
You will see parameter names in URL for these fields.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Guidance with Rest API
« Reply #5 on: November 14, 2023, 10:49:39 PM »
Got it, thank you very much, probably will be helpful for other fields too.
Information and great tips make miracles :) i might even build something out of this.
It's already gone into my ESB and it's working  :)

*

MB Themes

Re: Guidance with Rest API
« Reply #6 on: November 15, 2023, 08:53:56 AM »
Cool
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Smithtech

  • ****
  • 219 posts
Re: Guidance with Rest API
« Reply #7 on: November 16, 2023, 01:21:45 PM »
The example is great and allowed me to test adding listings, thanks for that.

I now hit another problem. I added some custom fields (native osclass function, not plugin) that i use in some categories.

Can i use custom field in the API, and how ?


@[email protected], were you able to add listings with pictures?
If yes, could you please share how you went about it?

Had installed this plugin months ago but couldn't figure out some of the API calls especially, posting listings with picture. Because of these limitations, we are unable to use the plugin.

Thank you very much

Re: Guidance with Rest API
« Reply #8 on: November 18, 2023, 02:06:44 PM »
Sure, I'm still learning also and getting help so happy to help with what I know.

I'me using fusion-project.org so it's a bit different the way I present the code and also it's in python, but I'm migrating this part of the project to full PHP.

I'll convert the examples I have and post here the result and example that I have working.

Since I'm away I'll need some time but don't worry as I'll post it here.

Just for your guidance the reply from MB Themes earlier was a big help, and actually for the API we should have a sort of cookbook that other can look into and use as there examples.

https://forums.osclasspoint.com/rest-api-plugin/post-new-ad-with-images/

Re: Guidance with Rest API
« Reply #9 on: November 19, 2023, 01:45:55 AM »
For the moment import the json file into your postman and select the body tab.
It's the same as the one shared on the link.
In the body you'll find the photos in the form data.
First delete the selected ones, they are from the author and do not existe in your laptop or server, and you'll get a file selector to add yours.
Hope this helps.
I'm still working on this but I'll post it here.

The cookbook would really be helpful, starting with simple examples for better understanding and afterwords moving forward to more complex ones :-)
« Last Edit: November 19, 2023, 02:07:24 AM by [email protected] »

*

MB Themes

Re: Guidance with Rest API
« Reply #10 on: November 19, 2023, 11:40:42 AM »
If plugin require advanced coding experience, what you said is essential.
Its also expected you are able to check source code, parameters and its processing.
Using plugin without sufficient skills is like buying book without reading skills.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Guidance with Rest API
« Reply #11 on: November 26, 2023, 04:29:09 AM »
The example is great and allowed me to test adding listings, thanks for that.

I now hit another problem. I added some custom fields (native osclass function, not plugin) that i use in some categories.

Can i use custom field in the API, and how ?


@[email protected], were you able to add listings with pictures?
If yes, could you please share how you went about it?

Had installed this plugin months ago but couldn't figure out some of the API calls especially, posting listings with picture. Because of these limitations, we are unable to use the plugin.

Thank you very much

Regarding the post with photos i'm exploring with some that is running but still didn't updated the photo, although everything looks ok.
Since my code is python i don't know if it's useable here so I asked Bard to convert to php didn't have the time to test it, probably needs to be corrected, so attached the python.
« Last Edit: November 26, 2023, 04:49:48 AM by [email protected] »

*

MB Themes

Re: Guidance with Rest API
« Reply #12 on: November 26, 2023, 11:42:22 AM »
I do not think path to photos is OK. Do not think photos will exists on same server when you trying to import listings.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Guidance with Rest API
« Reply #13 on: November 26, 2023, 01:10:26 PM »
Thanks, you are correct, naturally.
I'm simulating being on my laptop or being an external CRM to osclass, so the path will be local to those, there must be better ways to do it of course.

*

Smithtech

  • ****
  • 219 posts
Re: Guidance with Rest API
« Reply #14 on: December 02, 2023, 02:47:50 PM »
Sure, I'm still learning also and getting help so happy to help with what I know.

I'me using fusion-project.org so it's a bit different the way I present the code and also it's in python, but I'm migrating this part of the project to full PHP.

I'll convert the examples I have and post here the result and example that I have working.

Since I'm away I'll need some time but don't worry as I'll post it here.

Just for your guidance the reply from MB Themes earlier was a big help, and actually for the API we should have a sort of cookbook that other can look into and use as there examples.

https://forums.osclasspoint.com/rest-api-plugin/post-new-ad-with-images/

Alright. Thank you very much.
If you have any updates