magento api connect error - api

Getting all customer list and create a new customer using soap api...
$proxy = new SoapClient('http://j-shop.z/shop/api/soap/?wsdl');
// $proxy = new SoapClient(null, array('uri' => http://j-shop.z/shop/api/soap/?wsdl"));
$sessionId = $proxy->login('testuser', 'test123');
var_dump($proxy->call($sessionId, 'customer.list', array('filters', '*')));
$newCustomer = array(
'firstname' => 'First',
'lastname' => 'Last',
'email' => 'test#example.com',
'password_hash' => md5('password'),
'store_id' => 0,
'website_id' => 0
);
$newCustomerId = $proxy->call($sessionId,'customer.create',array($newCustomer));

Open php_soap in your wamp or xammp,
I think its not open,
So firstly you check your php.ini file

also try it
i think problem in api.xml
http://www.magentocommerce.com/api/soap/introduction.html
http://inchoo.net/ecommerce/magento/magento-v2-soap-demystified/

please set fault in api.xml so easily fix it

Related

shopware 6 upload multiple product variation images

Can we upload multiple image to the variation using API. Single image upload can be possible using below code, but not sure about multiple image upload.
$mediaId ='random string';
$url = $images['url'];
$mediaData = array(
array(
'id' => $mediaId,
'mediaFolderId' => $mediaFolderID,
),
);
$mediaDataArr = array(
'payload' => array(
"action" => "upsert",
"entity" => "media",
'payload' => $mediaData,
),
);
$createMedia = $shopware6HelperObj->post('_action/sync', $mediaDataArr);
$urlArr = array(
'url' => $url,
);
$parts = pathinfo($url);
$params = array(
'extension' => $parts['extension'],
'fileName' => $parts['filename'] . '__' . md5(time()),
);
$uploadImage = $shopware6HelperObj->post('_action/media/' . $mediaId . '/upload', $urlArr, $params);
Please suggest if any idea.
I always recommend to try doing that via the Admin Panel and check the Browser's Dev Tools / Network Tab which requests are made. This can give you a good hint on how do to it programmatically.

Pardot API: Add new prospect to certain list

$prospectData = array(
'user_key' => $user_key,
'api_key' => $api_key,
'first_name' => $firstName,
'last_name' => $lastName,
'city' => $city,
'state' => $state,
'comments' => $comments
);
callPardotApi('https://pi.pardot.com/api/prospect/version/4/do/create/email/'.$email, $prospectData);
I'm able to create a new prospect with a form that I have. It inserts all the data I supplied it (name, city, state, etc), but I need to also add this prospect to a list.
I tried adding to my $prospectData things like list => '1234' or "list_id" => '1234', but that doesn't seem to be working.
Is this possible to do? I know I can assign a prospect to a list via another api route using their ID, but I need this prospect to be added immediately upon form submit
Well it's not exactly ideal, but I had to do a new api call after creating the user.
$addprospect = callPardotApi('https://pi.pardot.com/api/prospect/version/4/do/create/email/'.$email, $prospectData);
$addprospectxml = new SimpleXMLElement($addprospect);
$id = $addprospectxml->prospect->id;
$listData = array(
'user_key' => $user_key,
'api_key' => $api_key,
'list_32106' => "1"
);
$updateProspect = callPardotApi('https://pi.pardot.com/api/prospect/version/4/do/update/id/'.(String)$id[0], $listData);
When creating a prospect, it will return XML with the newly crated prospect's ID. that ID can be used in a new api update call where you can set the list.

mindbody api post CustomClientFields

Im using the API class from Mindbody GetClientServices to access the MindBody Api. Works great.
Now i need to add custom values to the client defined in the Mindbody CMS (ie exmployer)
So this is the array i am using:
array('UpdateAction'=>'Update',
'Clients'=>array(
'Client'=>array(
'ID'=>'100015637',
'FirstName'=>'dummy'.$i,
'LastName'=>'Galaxy'.$i,
'BirthDate'=>'2010-05-24T18:13:00', //https://stackoverflow.com/questions/2899332/not-a-valid-allxsd-value
'Username'=> 'helloDummy1'.$i,
'Password'=> 'amin1216$1'.$i,
'Email'=>'dummy'.$i.'#noblestreet.eu',
'EmailOptIn'=> new SoapVar('true', XSD_STRING, 'xsd:boolean'),
'SendEmail'=> new SoapVar('true', XSD_STRING, 'xsd:boolean'),
'MobilePhone'=>'9770534045',
'HomePhone'=>'9770534045',
'WorkPhone'=>'9770534045',
'Address'=>'dummy'.$i,
'Address2'=>'dummy'.$i,
'City'=>'dummy'.$i,
'State'=>'ZH',
'Country'=>'NL',
'PostalCode'=>'2511HA',
'ForeignZip'=>'2511HA',
'Bio'=>'dummy'.$i,
'Status'=>'active',
'CustomClientFields' => array(
'CustomClientField'=> array(
0 => array(
'ID' => '1',
'value'=>'test'
)
)
)
)
)
);
On posting this to the API the customfield doesnt get added and i cant see it in the MB cms.
Any help on this one?
btw inserting/updating other values works
The comment made by Yuga was the correct answer:
1) Post resulting XML request you're sending to Mindbody API.
2) Try comparing your XML to the example XML updating custom fields shown on https://developers.mindbodyonline.com/Develop/ClientService.
3) Which XML response do you get? You may get an error, I suppose.
4) Most probably you need to send 'Value' not 'value'.
5) Make sure you send <Fields><string>Clients.CustomClientFields</string></Fields> in your XML request
Point 4 (correcting the typo value to Value) solved my problem.
For me we need to provide additional information like the below.
CustomclientFields
ID
DataType
Name
Value
Here is the example
'CustomClientFields' => array( 'CustomClientField'=> array(
0 => array('ID' => 1, 'DataType' => 'Number', 'Name' => 'txtCustom1', 'Value'=>121212121212, ),
1 => array('ID' => 2, 'DataType' => 'Number', 'Name' => 'txtCustom2', 'Value'=>121212, ),
2 => array('ID' => 3, 'DataType' => 'Text', 'Name' => 'txtCustom3', 'Value'=>Sampletext, ) )

zend framework 2 autentification using DbTable failure

I have followed the zend instructions for implement my web Authentication using a database table.
It's exactly the same code, but when render the page, the following exceptions appears:
Zend\Authentication\Adapter\Exception\RuntimeException
File:
C:\xampp\htdocs\pfc\vendor\ZF2\library\Zend\Authentication\Adapter\DbTable.php
Mensaje:
The supplied parameters to DbTable failed to produce a valid sql statement, please
check table and column names for validity.
produced by this other:
Zend\Db\Adapter\Exception\InvalidQueryException
File:
C:\xampp\htdocs\pfc\vendor\ZF2\library\Zend\Db\Adapter\Driver\Mysqli\Statement.php
Mensaje:
Statement couldn't be produced with sql: SELECT `users`.*, (CASE WHEN `password` = ?
THEN 1 ELSE 0 END) AS `zend_auth_credential_match` FROM `users` WHERE `mail` = ?
Seems to be that Statement.php can not execute the sql of above, but I send the sql by phpmyadmin replacing the ? for strings and work ok.
I am sure that $dbAdapter works ok also because I have tested it and the columns name are
"mail" and "password".
This in my code, also I put the $dbAdapter test code.
$dbAdapter = new DbAdapter(array( //This DbAdapter Work ok sure!!
'driver' => 'Mysqli',
'database' => 'securedraw',
'username' => 'root',
'password' => ''
));
$fp = function($name) use ($dbAdapter) { return $dbAdapter->driver->formatParameterName($name);};
$sql = 'SELECT * FROM ' . $qi('users') . ' WHERE id = ' . $fp('id');
$statement = $dbAdapter->query($sql);
$parameters = array('id' => 1);
$sqlResult = $statement->execute($parameters);
$row = $sqlResult->current();
$mail = $row['mail'];
$password = $row['password']; //until here test $dbAdapter exitly!!
//Start the auth proccess!!
$authAdapter = new AuthDbTableAdapter($dbAdapter);
$authAdapter->setTableName('users')
->setIdentityColumn('mail')
->setCredentialColumn('password');
$authAdapter->setIdentity('josep')
->setCredential('josep');
$authResult = $authAdapter->authenticate(); //This is the fail method!!!
After more research on the subject, I discovered that if changed the driver of the dbAdapter to pdo_mysql, authenticate method works ok.
The problem is I don't want use PDO because the SGBD won't change in the future.
Somebody know because happen this?
This may seems old but I was able to solve this error. This error is caused from you MySQL version.
This one works for me. All you need to do is to remove the driver_options from your db setup, this code is usually located at your global.php or .local.php from your Config file.
Change FROM:
'db' => array(
'driver' => 'Pdo_Mysql',
'dsn' => 'mysql:dbname=dbName;host=localhost',
'username' => 'dbUser',
'password' => 'dbPass',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
TO
'db' => array(
'driver' => 'Pdo_Mysql',
'dsn' => 'mysql:dbname=dbName;host=localhost',
'username' => 'dbUser',
'password' => 'dbPass',
),
Thank you. This solution solved my problem.

Set Magento Attribute to Configurable Product with Soap API

I need to create a new configurable product via Magento Soap API and add a related product to it.
I use this code that create 2 products ( one simple and one configur. ) then i try to link the simple one to the config one...this don't work..
There is a tutorial for do that??
Any help??
Many thanks.
// Magento login information
$mage_url = 'http://test.de/api/?wsdl';
$mage_user = 'admin';
$mage_api_key = 'admin';
// Initialize the SOAP client
$soap = new SoapClient( $mage_url );
// Login to Magento
$session = $soap->login( $mage_user, $mage_api_key );
$attributeSets = $soap->call($session,'product_attribute_set.list');
$set = current($attributeSets);
$sku = 'iphone-12345';
//configurable
$newProductData = array(
'name' => 'iPhone',
'websites' => array(1),
'short_description' => 'short description',
'description' => 'description',
'price' => 150,
'status' => '1',
'categories' => array(138),
);
$newProductRelated = array(
'name' => 'iPhone',
'websites' => array(1),
'short_description' => 'short description',
'description' => 'description',
'price' => 150,
'status' => '1',
'sku' => '2551464'
);
$productId = $soap->call($session,'product.create',array('configurable', $set['set_id'], $sku ,$newProductData));
$productId2 = $soap->call($session,'product.create',array('simple', $set['set_id'], $newProductRelated['sku'] ,$newProductRelated));
$soap->call($session, 'product_link.assign', array('configurable', $sku, $newProductRelated['sku'], array('position'=>0, 'colore'=> 21, 'qty'=>6)));
mant thx again.
Dealing with a similar issue and resorted to using the CSV import to create the relation for products imported from the API. This may may be a usable approach for a one time import via a generated CSV.