2

What I'm trying to do is use Magento's SOAP API v2 in Powershell to update products, create products, manage categories, etc.

So the simplest way I've found so far is from this page.

Here's a bit of what I have as far as logging in (and it does log in successfully)-

$uri = "http://mydomainname.com/api/v2_soap?wsdl=1"
$proxy = new-webserviceproxy $uri
$sessionid = $proxy.login("username","password")

Now, I should be able to put in things like $proxy.catelogproductinfo($sessionid,(a sku number), (a store number)) and get back product info for a specified product.

My problem is that I don't quite know what's wrong with some of the syntax I'm using. For that method above, here is Magento's devdocs help page.

It seems like even if an argument is marked as optional, if I leave it out of my request, I get an error saying it expected more arguments. It also looks like it's expecting an array for the fourth parameter, but when I try to enter it as an array (either written literally in the request, or as a variable) the API returns an error saying it can't read it.

For methods that I'm able to fill out all arguments for, the API does work and reply with what I'm looking for. I successfully got information on a category in Magento using this method. That call required a hash table, which I constructed in the form of $hash = @{"value1" = "something";"value2" = "something2"}.

Is there an easier way altogether to communicate with an API through Powershell? I tried some methods of invoke-webrequest, and Magento also offers a REST API, but I couldn't get anything else to work other than what I have above.

EDIT: so I figured out that if I just add $null to the optional arguments, it accepts them. But I still don't know how to enter an argument when it asks for an array.

  • Note: I'm sure it's a typo, but it should be catalogproductinfo rather than catelog – Robbie Averill Jun 19 '16 at 0:32
  • So after some more exploring, I narrowed down my problem to a specific situation when I have to update a product's info. We have custom attributes, so from this page I should be able to use the "additional_attributes" parameter, but every way I've worded it I can't get it to work. – Matthew Goode Jun 20 '16 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.