Method Community

 

Unable to get a response for some V2 API methods using PHP (some work fine)

Last post 10-17-2013 9:04 PM by dbornet. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 10-15-2013 5:35 PM

    Unable to get a response for some V2 API methods using PHP (some work fine)


    Hi,

    I am using PHP to access the API webservice.

     

    First attempt:

    $soap = new SoapClient("https://www.methodintegration.com/MethodAPI/service.asmx?WSDL", array('trace' => true));

    $result = $soap->MethodAPITableListV2(array(  "strCompanyAccount" => "mycompany",  "strLogin" => "mylogin",  "strPassword" => "mypassword" ));

    Result: This works perfectly.  In $result it returns a nice XML with a response of "Success" and all the tables.

     

    Second attempt:

    $soap = new SoapClient("https://www.methodintegration.com/MethodAPI/service.asmx?WSDL", array('trace' => true));

    $result = $soap->MethodAPIFieldListV2(array(  "strCompanyAccount" => "mycompany",  "strLogin" => "mylogin",  "strPassword" => "mypassword", "strTable" => "Customer" ));

    Result: Nothing.  No response.  It never returns.  No error, it just hangs.  Stops dead.

     

    Third attempt:

    $soap = new SoapClient("https://www.methodintegration.com/MethodAPI/service.asmx?WSDL", array('trace' => true));

    $result = $soap->MethodAPIFieldList(array(  "strCompanyAccount" => "mycompany",  "strLogin" => "mylogin",  "strPassword" => "mypassword", "strTable" => "Customer" ));

    The only thing I changed here was to remove the "V2" from function name.

    Result: Works perfectly.

     

    Since the API manual only lists the V2 functions and not the plain (without "V2") functions, and since the Table one works fine in V2 but the FieldList one doesn't, it looks like there are some issues with the V2 vs plain functions.

     

    FYI.

  • 10-16-2013 4:35 PM In reply to

    Re: Unable to get a response for some V2 API methods using PHP (some work fine)


    Hi dbornet,

    I think you're a little confused....the function signatures on the V2-less functions are not the same as the v2 functions...so if you do not pass the right parameters correct behaviour will not happen. I'll give C# examples below, I write my reponses to a label.

    MethodAPITableList

    string XMLToReturn = "";

    MethodAPI.Service _MethodAPI = new MethodAPI.Service();

    lblMethodAPITableList.Text = _MethodAPI.MethodAPITableList(CompanyAccount, Login, Password, ref XMLToReturn);

    lblMethodAPITableListXMLToReturn).Text =XMLToReturn;

    _MethodAPI.Dispose();

    MethodAPITableListV2

    MethodAPI.Service _MethodAPI = new MethodAPI.Service();

     lblMethodAPITableListV2.Text = _MethodAPI.MethodAPITableListV2(CompanyAccount, Login, Password, "");

    _MethodAPI.Dispose();

     

    Notice on the the v2-less function it's expecting xmlReturned passed in via reference as the 4th parameter, but v2 is expecting strSessionID passed in via value as the 4th parameter

    MethodAPIFieldList

    string XMLToReturn = "";

    MethodAPI.Service _MethodAPI = new MethodAPI.Service();

    lblMethodAPIFieldList.Text = _MethodAPI.MethodAPIFieldList(CompanyAccount, Login, Password, ref XMLToReturn, "Customer");

    lblMethodAPIFieldXMLToReturn;.Text = XMLToReturn;

    _MethodAPI.Dispose(); 

    MethodAPIFieldListV2

    MethodAPI.Service _MethodAPI = new MethodAPI.Service();

     lblMethodAPIFieldListV2.Text = _MethodAPI.MethodAPIFieldListV2(CompanyAccount, Login, Password, "", "Customer");

    _MethodAPI.Dispose();

    Same as with the table functions, the 4th parameter is different., so you cannot invoke them exactly the same way.

     

    Dave

  • 10-17-2013 9:04 PM In reply to

    Re: Unable to get a response for some V2 API methods using PHP (some work fine)

    Thanks I had missed that the strSessionId parameter was required.  The documentation states

    "If you know the unique current SessionID of a signed in user, you can pass this instead of strPassword", which makes it sound like an optional parameter, whereas in fact it has to be passed always, at least as an empty string.

    I added the parameter as an empty string and all is now well, thanks.

Page 1 of 1 (3 items)