Jump to content
  • 0

How To Add Clients From Api


MashterSoporte

Question

8 answers to this question

Recommended Posts

  • 0

Have you read the documentation regarding the API?

 

Have you tried to use the API SDK to help simplify making API calls?

 

Have you looked at the source documention regarding the creation of clients? You can make a call to Clients::create to create a user account, client account, and contact in Blesta by passing all of the necessary information from data you retrieve from your current customer list.

Link to comment
Share on other sites

  • 0

Have you read the documentation regarding the API?

 

Have you tried to use the API SDK to help simplify making API calls?

 

Have you looked at the source documention regarding the creation of clients? You can make a call to Clients::create to create a user account, client account, and contact in Blesta by passing all of the necessary information from data you retrieve from your current customer list.

I downloaded the API SDK, i cant get a response, but i use a HTTP Client (Chrome Extension - Boomerang) and get a response with the clients information, i try with "http://domain.com/api/clients/add/post.json"sending the params of add client form but i get this:

"{

    "message": "The format requested is not supported by the server.",
    "response": null

}"

Link to comment
Share on other sites

  • 0

I sending to domain.com/api/clients/create.xml with method POST

<?xml version="1.0" encoding="UTF-8" ?>
<vars>
	<username>fulanito</username>
	<new_password>mash123</new_password>
	<confirm_password>mash123</confirm_password>
	<client_group_id>1</client_group_id>
	<status>active</status>
	<firstname>Fulanito</firstname>
	<last_name>De tal</last_name>
	<email>fulanito@email.com</email>
	<state>AGU</state>
	<country>MX</country>
	<zip>27000</zip>
	<settings>
		<default_currency>MXN</default_currency>
		<language>es_es</language>
		<username_type>username</username_type>
		<tax_id />
		<tax_exempt>true</tax_exempt>
		<send_registration_email>false</send_registration_email>
	</settings>
</vars>

And get this response

HTTP/1.1 400 "Bad Request" 1317ms

Date: Thu, 07 Apr 2016 22:12:11 GMT
Server: Apache/2.2.15 (CentOS)
Connection: close
X-Powered-By: PHP/5.3.3
Content-Length: 369
Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8" ?>
<clients>
	<message>The request cannot be fulfilled due to bad syntax.</message>
	<errors>
		<username>
			<empty>Por favor, introduce un nombre de usuario.</empty>
		</username>
		<new_password>
			<format>Por favor ingrese una contraseña de al menos 6 caracteres.</format>
		</new_password>
	</errors>
	<response />
</clients>

Whats is wrong?

Link to comment
Share on other sites

  • 0

in the previous post i am using a Chrome extension HTTP Client (Boomerang) beacause i cant use the SDK

 

This is my PHP Code if i use the API SDK

<?php

require_once 'api/blesta_api.php';

$user = "isaac";
$key = "a5-----------------0f4f";
$url = "http://domain.com/api";

$api = new BlestaApi($url, $user, $key);

$args = array(
    'vars' => array(
        'username' => 'fulanito',
        'new_password' => 'Mash.123',
        'confirm_password' => 'Mash.123',
        'client_group_id' => 1,
        'first_name' => 'Fulanito',
        'last_name' => 'De tal',
        'email' => 'fulanito@moesbar.com',
        'state' => 'AGU',
        'country' => 'MX',
        'zip' => '27000',
        'settings' => array(
            'default_currency' => 'MXN',
            'language' => 'es_es',
            'tax_exempt' => true,
            'send_registration_email' => false
        )
    )
);

$response = $api->post('clients', 'create', $args);

var_dump($response);

The var_dump show this:

object(BlestaResponse)#2 (2) {
  ["raw":"BlestaResponse":private]=>
  string(0) ""
  ["response_code":"BlestaResponse":private]=>
  int(302)
}
Link to comment
Share on other sites

  • 0

Can you dump the response and any errors?

i.e.

print_r($response->response());
print_r($response->errors());

What you have looks like it should work to me. Are you able to perform a simpler action, like the example in the docs--fetching a user by ID?

$response = $api->get("users", "get", array('user_id' => 1));
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...