thewizarodofoz / google-ad-manager-api

A modern wrapper around Google's Ad Manager API.
18 stars 16 forks source link

Error running functions with no parameters: Error: soap:Server: No binding operation info while invoking unknown method with params unknown. #13

Closed linus closed 3 years ago

linus commented 3 years ago

When running a function that takes no parameters, eg NetworkService.getCurrentNetwork(), the client fails with

Error: soap:Server: No binding operation info while invoking unknown method with params unknown.

The request to NetworkService contains no information about the requested method (soap:Body is empty):

<?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:tns="https://www.google.com/apis/ads/publisher/v202102" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"><soap:Header><RequestHeader soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xsi:type="ns1:SoapRequestHeader" xmlns:ns1="https://www.google.com/apis/ads/publisher/v202102" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><ns1:networkCode>[REMOVED]</ns1:networkCode><ns1:applicationName>content-api</ns1:applicationName></RequestHeader></soap:Header><soap:Body></soap:Body></soap:Envelope>

However, passing an empty object works, so that NetworkService.getCurrentNetwork({}) returns info about the current network, with the SOAP request body being:

<?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:tns="https://www.google.com/apis/ads/publisher/v202102" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"><soap:Header><RequestHeader soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xsi:type="ns1:SoapRequestHeader" xmlns:ns1="https://www.google.com/apis/ads/publisher/v202102" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><ns1:networkCode>[REMOVED}</ns1:networkCode><ns1:applicationName>content-api</ns1:applicationName></RequestHeader></soap:Header><soap:Body><getCurrentNetwork xmlns="https://www.google.com/apis/ads/publisher/v202102"></getCurrentNetwork></soap:Body></soap:Envelope>
pzagor2 commented 3 years ago

I'm trying to get a valid networkCode for the authenticated user.

I'm getting an error stating that I need to pass in a networkCode, but per ad manager documentation https://developers.google.com/ad-manager/api/soap_xml getCurrentNetwork does not require thenetworkCode

const dfp1 = new DFP({networkCode: 'doesnotmatter', apiVersion: 'v202102'});
const networkSerivce = await dfp1.getService('NetworkService', dfpAccessToken);
const res = await networkSerivce.getCurrentNetwork({}); //we need to pass in empty object
Error: soap:Server: [AuthenticationError.NETWORK_NOT_FOUND @ ; trigger:'doesnotmatter']: {"ApiExceptionFault":{"message":"[AuthenticationError.NETWORK_NOT_FOUND @ ; trigger:'doesnotmatter']","errors":{"attributes":{"xsi:type":"AuthenticationError"},"fieldPath":"","trigger":"doesnotmatter","errorString":"AuthenticationError.NETWORK_NOT_FOUND","reason":"NETWORK_NOT_FOUND"}}}

I tried omitting the networkCode from the object parameter, same problem.

@linus You workaround with an empty object works great. Thank you for that.

It does work if I pass in a valid networkCode, but I'm trying to get the code on behave of my users so they don't need to copy it from the GAM UI.

Did anyone else had a similar issue?

pzagor2 commented 3 years ago

OK, I found the issue. I was using getCurrentNetwork instead of getAllNetworks.

It works If I call the API like this.

const dfp1 = new DFP({networkCode: 'doesnotmatter', apiVersion: 'v202102'});
const networkSerivce = await dfp1.getService('NetworkService', dfpAccessToken);
const res = await networkSerivce.getAllNetworks({}); //we need to pass in empty object