locked
API login error

    Question

  • Hi,

      I can not log into the API to get my account IDs. So my kind MSN contact got them for me and emailed me the SOAP packed he used. As far as I can tell his SOAP and my SOAP is identical. Can anyone point out where I am going wrong and why I can not log in?

    Hi SOAP that works:

    Code Snippet

    <?xml version="1.0" encoding="utf-8"?>

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <soap:Header>

    <ApiUserAuthHeader xmlns="http://adcenter.microsoft.com/syncapis">

    <UserName>xxx</UserName>

    <Password>xxx</Password>

    <UserAccessKey>xxx</UserAccessKey>

    </ApiUserAuthHeader>

    </soap:Header>

    <soap:Body>

    <GetAccounts xmlns="http://adcenter.microsoft.com/syncapis"><APIFlags>0</APIFlags></GetAccounts>

    </soap:Body>

    </soap:Envelope>


    My SOAP that does not work:

    Code Snippet

    <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://adcenter.microsoft.com/syncapis" xmlns:ns2="http://adcenter.microsoft.com/syncapis">

    <SOAP-ENV:Header>

    <ns2:ApiUserAuthHeader>

    <UserName>xxx</UserName>

    <Password>xxx</Password>

    <UserAccessKey>xxx</UserAccessKey>

    </ns2:ApiUserAuthHeader>

    </SOAP-ENV:Header>

    <SOAP-ENV:Body>

    <ns1:GetAccounts><ns1:APIFlags>0</ns1:APIFlags></ns1:GetAccounts>

    </SOAP-ENV:Body>

    </SOAP-ENV:Envelope>



    The funny part is that my initial contact with the API and my MSN contact was June 2nd!! I got google API, Yahoo and Miva all working within a couple of hours :-) MSN has taken me 2 months and I still haven't got to step 1 "Get the Account ID" haha! I WILL NOT GIVE UP!!! (please help me tho :-)

    My error: soapTongue Tiederver Server was unable to process request. ---> |-400001|-1|API unauthorized access|.

    1: Is my namespace correct?
    2: Is it something to do with my IP address so my machine is unauthorized?

    cheers,
    john
    Monday, July 21, 2008 1:30 PM

Answers

  • Code Snippet

     

    $soap = <<<EOT

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
        <ApiUserAuthHeader xmlns="http://adcenter.microsoft.com/syncapis">
          <UserName>xxx</UserName>
          <Password>xxx</Password>
          <UserAccessKey>xxx</UserAccessKey>
        </ApiUserAuthHeader>
      </soap:Header>
      <soap:Body>
        <GetAccounts xmlns="http://adcenter.microsoft.com/syncapis">
          <APIFlags>0</APIFlags>
        </GetAccounts>
      </soap:Body>
    </soap:Envelope>

    EOT;

     

    $soap = trim( $soap );
    $soap = str_replace( "\n", '', $soap );
    $url = 'https://adcenterapi.microsoft.com/v4/CustomerManagement/CustomerManagement.asmx';


    $ch = curl_init( $url );
    curl_setopt( $ch, CURLOPT_HEADER, 0 );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
     "Content-Type: text/xml; charset=UTF-8",
     "Content-Length: ". strlen( $soap )
     ));

    curl_setopt( $ch, CURLOPT_POST, 1 );
    curl_setopt( $ch, CURLOPT_POSTFIELDS, $soap );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt( $ch, CURLOPT_TIMEOUT, 240 );
    $soapResults = curl_exec($ch);
    curl_close($ch);
    echo $soapResults;

     

    exit();

     

     

    OK, the above code works for me. Hope that helps some people :-)

     

    monk.e.boy

    Thursday, July 24, 2008 10:09 AM

All replies

  • You are correct that it appears to be a namespace issue. Although ns1 and ns2 point to the same URL, you'll want to use ns1 in both places.

    Jeff Dillon, API Support

    Monday, July 21, 2008 5:25 PM
    Owner
  • I have exactly the same problem.
    It works fine if I use the CampaignManagementService but it does not work with the CustomerManagement. Same error.

    The support does not know what to answer except "Send me this, send me that" at a really low pace. My question: is it normal that Accounts related services and methods are still under the com.microsoft.adcenter.syncapis package and not under the com.microsoft.adcenter.api.advertiser.v5 package as the other services?
    Tuesday, July 22, 2008 8:37 AM
  • OK, I will try to change how the SOAP is made. So this is a valid SOAP packet but it is the code at your end that is broken? Or is the SOAP packet invalid?

    Thanks for the quick reply :-)

    monk.e.boy
    Tuesday, July 22, 2008 9:19 AM
  • We ask for information that we need to diagnose the issue, and answer questions as quickly as we can. V5 CampaignManagement and Reporting use the new authentication. We kept the other verticals as is using the previous V4 style in an effort to reduce code migration.

    Hope this helps.

    Jeff Dillon, API Support

    Tuesday, July 22, 2008 6:25 PM
    Owner
  • Not sure of your question. You have one SOAP packet that works, the other doesn't, and I mentioned the namespace differences between the two. I suspect our web service is looking for a consistent namespace. Let us know how it works for you?

    thanks

    Jeff Dillon, API Support

     

    Tuesday, July 22, 2008 6:30 PM
    Owner
  • >> We kept the other verticals as is using the previous V4 style in an effort to reduce code migration.

    Got any working PHP examples for V4?

    This whole thread is us PHPers trying to get data out of the V4 API.

    monk.e.boy
    Thursday, July 24, 2008 8:22 AM
  • OK ladies. I've decided the only way to figure this out is to go old skool and post raw SOAP to the server:

     

    Code Snippet

     

    $soap = <<<EOT

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
        <ApiUserAuthHeader xmlns="http://adcenter.microsoft.com/syncapis">
          <UserName>xxx</UserName>
          <Password>xxx</Password>
          <UserAccessKey>xxx</UserAccessKey>
        </ApiUserAuthHeader>
      </soap:Header>
      <soap:Body>
        <GetAccounts xmlns="http://adcenter.microsoft.com/syncapis">
          <APIFlags>0</APIFlags>
        </GetAccounts>
      </soap:Body>
    </soap:Envelope>

    EOT;

     

    $soap = trim( $soap );
    $soap = str_replace( "\n", '', $soap );

    $url = 'https://adcenterapi.microsoft.com/v4/CustomerManagement/CustomerManagement.asmx';


    $ch = curl_init( $url );
    curl_setopt( $ch, CURLOPT_HEADER, 0 );
    curl_setopt( $ch, CURLOPT_POST, 1 );
    curl_setopt( $ch, CURLOPT_POSTFIELDS, $soap );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt( $ch, CURLOPT_TIMEOUT, 240 );
    $soapResults = curl_exec($ch);
    curl_close($ch);
    echo $soapResults;

     

     

    $soapResults === false

     

    I don't get an error message or any vaules. The weird thing is if I mess round with the SOAP packet I do get error messages.

     

    Any ideas?

     

    Thanks,

     

    monk.e.boy

    Thursday, July 24, 2008 9:50 AM
  • Code Snippet

     

    $soap = <<<EOT

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
        <ApiUserAuthHeader xmlns="http://adcenter.microsoft.com/syncapis">
          <UserName>xxx</UserName>
          <Password>xxx</Password>
          <UserAccessKey>xxx</UserAccessKey>
        </ApiUserAuthHeader>
      </soap:Header>
      <soap:Body>
        <GetAccounts xmlns="http://adcenter.microsoft.com/syncapis">
          <APIFlags>0</APIFlags>
        </GetAccounts>
      </soap:Body>
    </soap:Envelope>

    EOT;

     

    $soap = trim( $soap );
    $soap = str_replace( "\n", '', $soap );
    $url = 'https://adcenterapi.microsoft.com/v4/CustomerManagement/CustomerManagement.asmx';


    $ch = curl_init( $url );
    curl_setopt( $ch, CURLOPT_HEADER, 0 );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
     "Content-Type: text/xml; charset=UTF-8",
     "Content-Length: ". strlen( $soap )
     ));

    curl_setopt( $ch, CURLOPT_POST, 1 );
    curl_setopt( $ch, CURLOPT_POSTFIELDS, $soap );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt( $ch, CURLOPT_TIMEOUT, 240 );
    $soapResults = curl_exec($ch);
    curl_close($ch);
    echo $soapResults;

     

    exit();

     

     

    OK, the above code works for me. Hope that helps some people :-)

     

    monk.e.boy

    Thursday, July 24, 2008 10:09 AM