Choose Vendorplan When Creating A Vendor Through Api

Hi all!

Is it possible to choose an existing vendor plan when creating a vendor through the API? In the documentation I can not find any hints regarding this issue (https://docs.cs-cart.com/latest/developer_guide/api/entities/vendors.html#create-a-vendor).

I am running the CS Cart Multi Vendor Plus edition.

Looking forward to your answers!

Best regards

hummer

Hello

Did you try send PUT with params plan_id ?

Best regards

Robert

Hi Robert,

thanks for that hint! It works!

Can I then state that the API documentation is incomplete in some cases?

And, second question: the two warnings I get can be ignored?

PHP Notice

Message

Undefined index: email

Error at

app/functions/fn.companies.php, line: 834

Backtrace

File: app/functions/fn.companies.php
Line: 834
Function: {closure}
File: app/Tygh/Api/Entities/Stores.php
Line: 185
Function: fn_update_company
File: app/Tygh/Api.php
Line: 408
Function: update
File: app/Tygh/Api.php
Line: 332
Function: exec
File: app/Tygh/Api.php
Line: 281
Function: getResponseFromEntity
File: app/Tygh/Api.php
Line: 155
Function: getResponse
File: api.php
Line: 29
Function: handleRequest

PHP Warning

Message

Cannot modify header information - headers already sent by (output started at /var/www/cscart/app/Tygh/Tools/ErrorHandler.php:59)

Error at

app/Tygh/Api/Response.php, line: 249

Backtrace

File: app/Tygh/Api/Response.php
Line: 249
Function: {closure}
File: app/Tygh/Api.php
Line: 167
Function: send
File: api.php
Line: 29
Function: handleRequest
{"store_id":"189"}

Best regards

hummer

Hello

You can generally do updating all fields. It does not necessarily have to be described in the documentation.
As for the warning, it looks like you did not provide an email address when creating the vendor. You can complete this with the PUT method.
Best regards
Robert

Hi Robert,

understood!

Regarding the warnings:

This is how I create the vendor:

POST https://example.com/api/vendors/

{
  "company": "Test Company",
  "status": "A",
  "company_description": "",
  "storefront": "api",
  "email": "test_company@example.com",
  "phone": "555555555",
  "url": "http://example.com",
  "fax": "+555555555",
  "address": "Street 5",
  "city": "New York",
  "state": "NY",
  "country": "US",
  "zipcode": "00000"
}

This is how I update the vendor:

PUT https://example.com/api/vendors/227/

{
  "plan_id": "2"
}

Nevertheless I get these warnings as described above. Any ideas?

Best regards

hummer

Hello

1. Check if the admin vendor was created after adding the vendor.

2. In PUT add field email.

Best regards

Robert


Can I then state that the API documentation is incomplete in some cases?

Thanks for the morning chuckle!

Can I then state that the API documentation is incomplete in some cases?