-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rest: uploading OfflineConversionAdjustments fails #187
Comments
The problem seems to be
I am not familiar with jackson's serializers - Is it safe to use SimpleDateFormat as field in CalendarSerializer? It's not thread safe if multiple serialization tasks use the same serializer object, this could be problematic. |
thank you for raising this issue! SOAP requests use BingAds-Java-SDK/proxies/com/microsoft/bingads/v13/campaignmanagement/Adapter1.java Line 20 in e66576e
Looks like I'm checking if we can just use the same
Yeah the example in that section should be fixed or cleaned up. At least for recent CXF versions it should be enough to set Although I'm not sure if some logging filters set in the application might be causing the request logs to not be printed (at least it seems to work in a simple application with default settings) |
Your servers seem to need the time in format "yyyy-MM-dd'T'HH:mm:ss". That's why I provided the pull request #188 for This JSON-serializer is registered here BingAds-Java-SDK/src/main/java/com/microsoft/bingads/internal/restful/adaptor/AdaptorUtil.java Line 35 in b25e458
|
Well looks like for writing it as a UTC string there is an even simpler solution using Jackson only, we just need to disable one default feature it has: ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
System.out.println(mapper.writeValueAsString(Calendar.getInstance(TimeZone.getTimeZone("Europe/Berlin"))));
// "2024-05-09T17:20:50.989+00:00" I don't know why this is not the default behavior and instead it writes timestamps by default... But in any case, to fully match SOAP behavior it's probably better to send the time the same way, including the time zone that was set on the object (probably local time zone in most cases). System.out.println(jakarta.xml.bind.DatatypeConverter.printDateTime(Calendar.getInstance(TimeZone.getTimeZone("Europe/Berlin"))));
// 2024-05-09T19:41:23.601+02:00 We also wanted to update the deserializer so it has similar logic to the serializer (in this case using DatatypeConverter). 13.0.20.2 has these changes. Hopefully it works for now, but we can think more about alternatives (using Jackson only, if possible) |
It seems to work. My test-request containing I don't know if it's a problem that milliseconds are being sent now. With the previous formatter, only seconds were part of the timestamp. I will deploy my software next Monday. Then I can tell you if it works in production. |
uploading offline conversion works without problems with version 13.0.20.2 |
When trying to upload an offline conversion adjustment, the request fails with an
OperationError code=100,details=Invalid JSON at line 0 position XXX. Path: $.OfflineConversionAdjustments[0].AdjustmentTime
After looking at the request I found out, that an example payload looks like this
The AdjustmentTIme somehow got the TimeZone of the Calendar attached. I can do a workaround by explicitly setting the adjustment time's Calendar with TimeZone UTC, but with SOAP requests it was no problem to just use a standard calendar
Calendar.getInstance()
(with uses my standard time zone Europe/Berlin).By the way: You should update your troubleshooting section. With the current version of BingAds all the dependency versions should be updated to 4.0.2, otherwise NoClassDefFoundErrors occur.
I had a hard time to log the requests. I didn't manage it to do it "the SOAP way" that is explained in the troubleshooting section. The only way I was able to log the communcation was to modify my spring-configuration the way it is mentioned here and here and to log the data provided for loggers under
org.apache.cxf.services
.The text was updated successfully, but these errors were encountered: