Jump to content
  • 0

Api Client Create Issue


KingPin

Question

I am creating multiple clients for 3 total companies under 1 blesta license with addon companies.
I import from csv via curl calls and everything worked great for company #1. client ids went from 1500 - 1545.
When I create a client for a 2nd company I dont get a full response back with all the client data of the newly created client. its like its adding contacts instead of clients. I get a simple :

{"response":false}

 

And all the clients are created with ID 1546. If I create a client via the gui it gets ID 1547 and is created fine. has anyone noticed anything similar to this before?

 

 thank you.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Clients::create is one of those methods that does not accept a company_id parameter, and instead uses the configured company ID from the system. You probably received a false response because of an error validating the data (e.g. the username or email address was already taken).

 

If you wanted to work with a separate company over the API, you would need to use a different API user by configuring API Access for that user under the other company.

Link to comment
Share on other sites

  • 0

Thank you for the quick reply. I am currently quickly putting this together in bash and the following curl code works on company 1 but not company 2 : 

company1

curl -v http://site.com/api/clients/create.json -u user:key \
-d 'vars[client_group_id]=1' \
-d 'vars[status]=active' \
-d 'vars[company_id]=1' \
-d 'vars[first_name]=first' \
-d 'vars[last_name]=last' \
-d 'vars[company]=company' \
-d 'vars[username]=112233441' \
-d 'vars[new_password]=somepass1324' \
-d 'vars[confirm_password]=somepass1324' \
-d 'vars[email]=imports@site.com' \
-d 'vars[numbers][0][number]=+16465551234' \
-d 'vars[numbers][1][number]=+17185554321' \
-d 'vars[address1]=123 Front Street' \
-d 'vars[address2]=' \
-d 'vars[city]=Brooklyn' \
-d 'vars[state]=NY' \
-d 'vars[zip]=10000' \
-d 'vars[country]=US' \
-d 'vars[settings][username_type]=username' \
-d 'vars[settings][send_registration_email]=false' \
-d 'vars[custom][1]=12345' \
-d 'vars[custom][2]=12345

company 2

curl -v http://site.com/api/clients/create.json -u user:key \
-d 'vars[client_group_id]=2' \
-d 'vars[status]=active' \
-d 'vars[company_id]=2' \
-d 'vars[first_name]=first' \
-d 'vars[last_name]=last' \
-d 'vars[company]=company' \
-d 'vars[username]=112233442' \
-d 'vars[new_password]=somepass1324' \
-d 'vars[confirm_password]=somepass1324' \
-d 'vars[email]=imports@site.com' \
-d 'vars[numbers][0][number]=+16465551234' \
-d 'vars[numbers][1][number]=+17185554321' \
-d 'vars[address1]=123 Front Street' \
-d 'vars[address2]=' \
-d 'vars[city]=Brooklyn' \
-d 'vars[state]=NY' \
-d 'vars[zip]=10000' \
-d 'vars[country]=US' \
-d 'vars[settings][username_type]=username' \
-d 'vars[settings][send_registration_email]=false' \
-d 'vars[custom][3]=12345' \
-d 'vars[custom][4]=12345'
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...