Error occurs while calling:
admob.accounts.mediationReport.generate link
admob.accounts.networkReport.generate link
The problem is mediationReport response body and networkReport response body represents array type, but the library tries to parse responses as object type:
GenerateNetworkReportResponse
GenerateMediationReportResponse
NewtonsofJsonSerializer which used as default service serializer throws exception while parsing the responses.
Interesting - I don't think we've ever had an API where the response itself is just an array. Chris, any thoughts?
Sorry for not getting into this before - I assume it's still a problem? I'll try to investigate it myself this week.
Hi!
We found a workaround, but it looks like there is still a problem
I've just been looking into this, but unfortunately the documentation's sample JSON isn't even valid JSON - I'll raise this internally, but if you're able to capture an actual response (e.g. via Fiddler - or I can give you some code to fetch the response as a string) that would be really helpful. I'll try manually editing the sample response for the moment.
Okay, with a manual change to this line in the client library source code:
public class GenerateRequest : AdMobBaseServiceRequest<Google.Apis.AdMob.v1.Data.GenerateNetworkReportResponse[]>
... and a bit of editing of the JSON (just adding a comma or two) the code works.
Unfortunately I'm not sure whether or how that can be represented in the Discovery document. Just using "type": "array" and an items with a ref to GenerateNetworkReportResponse doesn't work, unfortunately. I'll need to look into this to work out what we want to do. Sorry for the inconvenience in the meantime.
Captured actual response (but removed some data rows except three - as they all looks the same and replaced our app id and app name). But this changes should not affect to response structure.
Response:
[
{
"header": {
"dateRange": {
"startDate": {
"year": 2020,
"month": 3,
"day": 22
},
"endDate": {
"year": 2020,
"month": 3,
"day": 23
}
},
"localizationSettings": {
"currencyCode": "USD"
}
}
},
{
"row": {
"dimensionValues": {
"APP": {
"value": "APP ID",
"displayLabel": "APP NAME"
},
"DATE": {
"value": "20200322"
},
"PLATFORM": {
"value": "Android"
},
"AD_SOURCE": {
"value": "1063618907739174004",
"displayLabel": "Applovin"
},
"COUNTRY": {
"value": "AD"
}
},
"metricValues": {
"CLICKS": {
"integerValue": "0"
},
"IMPRESSIONS": {
"integerValue": "0"
},
"AD_REQUESTS": {
"integerValue": "143"
},
"ESTIMATED_EARNINGS": {
"microsValue": "0"
},
"MATCHED_REQUESTS": {
"integerValue": "0"
},
"MATCH_RATE": {
"doubleValue": 0
}
}
}
},
{
"row": {
"dimensionValues": {
"APP": {
"value": "APP ID",
"displayLabel": "APP NAME"
},
"DATE": {
"value": "20200322"
},
"PLATFORM": {
"value": "Android"
},
"AD_SOURCE": {
"value": "1063618907739174004",
"displayLabel": "Applovin"
},
"COUNTRY": {
"value": "AE"
}
},
"metricValues": {
"CLICKS": {
"integerValue": "0"
},
"IMPRESSIONS": {
"integerValue": "2"
},
"AD_REQUESTS": {
"integerValue": "2093"
},
"ESTIMATED_EARNINGS": {
"microsValue": "0"
},
"IMPRESSION_CTR": {
"doubleValue": 0
},
"MATCHED_REQUESTS": {
"integerValue": "8"
},
"MATCH_RATE": {
"doubleValue": 0.003822264691829909
}
}
}
},
{
"row": {
"dimensionValues": {
"APP": {
"value": "APP ID",
"displayLabel": "APP NAME"
},
"DATE": {
"value": "20200322"
},
"PLATFORM": {
"value": "Android"
},
"AD_SOURCE": {
"value": "1063618907739174004",
"displayLabel": "Applovin"
},
"COUNTRY": {
"value": "AF"
}
},
"metricValues": {
"CLICKS": {
"integerValue": "0"
},
"IMPRESSIONS": {
"integerValue": "0"
},
"AD_REQUESTS": {
"integerValue": "408"
},
"ESTIMATED_EARNINGS": {
"microsValue": "0"
},
"MATCHED_REQUESTS": {
"integerValue": "1"
},
"MATCH_RATE": {
"doubleValue": 0.0024509803921568627
}
}
}
},
{
"footer": {
"matchingRowCount": "3638"
}
}
]
Okay, with a manual change to this line in the client library source code:
public class GenerateRequest : AdMobBaseServiceRequest<Google.Apis.AdMob.v1.Data.GenerateNetworkReportResponse[]>... and a bit of editing of the JSON (just adding a comma or two) the code works.
Unfortunately I'm not sure whether or how that can be represented in the Discovery document. Just using
"type": "array"and anitemswith a ref to GenerateNetworkReportResponse doesn't work, unfortunately. I'll need to look into this to work out what we want to do. Sorry for the inconvenience in the meantime.
Our workaround looks the same:
public class GenerateRequest : AdMobBaseServiceRequest< GenerateMediationReportResponse[] >
and
public class GenerateRequest : AdMobBaseServiceRequest< GenerateNetworkReportResponse[] >
I'm not sure it's right but it's works for us
Thanks, that works as expected.
As a temporary workaround, you could potentially just download the source file for the AdMob API (which is a single file) and modify the two request objects to just add [] in the type argument. You could either have that as a separate project, or a source file within your main project.
(This may be exactly the workaround you referred to earlier, of course.)
I'll start asking internally about this - but given how these things work, I wouldn't expect the generated library to be fixed in under a week, I'm afraid.
Reopening for now, as the change isn't live - will ping this issue when there's a release that contains it.
Fixed in version 1.45.0.1917 - I believe, anyway. Please let me know if you still have any problems.