Skip to content

Instantly share code, notes, and snippets.

@kandy
Last active October 7, 2015 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kandy/dd6592508c5774d9235d to your computer and use it in GitHub Desktop.
Save kandy/dd6592508c5774d9235d to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: akasian
* Date: 10/6/15
* Time: 9:45 AM
*/
ini_set('display_errors',1);
$token = "67ihe78il86214jgt8asjr9fhvl9i41r";
$baseUrl = 'http://mage.dev/rest/';
for ($i = 1; $i <= 10; $i ++) {
$postdata = json_encode([
"customer" => [
"email" => "user{$i}@example.com",
"firstname" => "John",
"lastname" => "Doe",
"addresses" => [
[
"defaultShipping" => true,
"defaultBilling" => true,
"firstname" => "John",
"lastname" => "Doe",
"region" => [
"regionCode" => "CA",
"region" => "California",
"regionId" => 12
],
"postcode" => "90001",
"street" => ["Zoe Ave"],
"city" => "Los Angeles",
"telephone" => "555-000-00-00",
"countryId" => "US"
]
]
]
]);
$opts = ['http' => [
'method' => 'POST',
'header' => implode("\n", [
"Authorization: Bearer " . $token,
'Content-type: application/json'
]),
'content' => $postdata
]];
$context = stream_context_create($opts);
var_dump(file_get_contents( $baseUrl . 'default/V1/customers/', null, $context));
}
@VLCSolutions
Copy link

you are calling customer request api each time for the each customer, but i want to send multiple customers in a single request

@VLCSolutions
Copy link

Stack Trace:

http://192.168.0.183/NewMagento2/soap?wsdl&services=customerCustomerRepositoryV1
loading http://192.168.0.183/NewMagento2/soap?wsdl&services=customerCustomerRepositoryV1
Acquiring the wsdl...
Resolving the wsdlendpoint...
Generating code...
Code generation failed.
Microsoft.FSharp.Core.FailureException: Assembly not yet created.
at Storm.Types.WebSvcManagerOps.clo@90.CreateWebServiceModel()
at <StartupCode$Storm>.$Type.bgworker.run@51@57_2.Invoke(DoWorkEventArgs dArgs)
at <StartupCode$Storm>.$Type.bgworker.run@51@57_1.Invoke(Object sender, DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

@kandy
Copy link
Author

kandy commented Oct 7, 2015

@VLCSolutions, can edit app/bootstrap.php file, uncomment ini_set('display_errors', 1); open http://192.168.0.183/NewMagento2/soap?wsdl&services=customerCustomerRepositoryV1 in browser and copy page structure in gist?

@VLCSolutions
Copy link

@kandy page is too long so i have copied part of the text

structure

@VLCSolutions
Copy link

@kandy Have you found the way to get XML request

@kandy
Copy link
Author

kandy commented Oct 7, 2015

no, sorry i have no idea what problem you have
for me all work fine

@VLCSolutions
Copy link

@kandy, Please find the first image which i'm able to get xml request by giving the url http://192.168.0.183/magento1131/api/v2_soap/?wsdl=1 in magento1

Observe the second image throwing error after giving the URL http://192.168.0.183/NewMagento2/soap?wsdl&services=customerCustomerRepositoryV1 to get the xml request in magento2

magento1_xml_request

magento2_xml_request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment