Notronix / JEtsy

A Java implementation of a Java version of the Etsy API
Apache License 2.0
6 stars 9 forks source link

[ISSUE] updateVariationImages sent variation_images=null #3

Closed hoanghiep closed 1 year ago

hoanghiep commented 3 years ago

v1.0.0012

Untitled

2020-11-13 11:39:45.737  INFO 8076 --- [eb-scheduling-1] c.google.api.client.http.HttpTransport   : -------------- REQUEST  --------------
POST https://openapi.etsy.com/v2/listings/903730831/variation-images
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: Google-HTTP-Java-Client/1.34.2 (gzip)
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 21

2020-11-13 11:39:45.737  INFO 8076 --- [eb-scheduling-1] c.google.api.client.http.HttpTransport   : curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: Google-HTTP-Java-Client/1.34.2 (gzip)' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -d '@-' -- 'https://openapi.etsy.com/v2/listings/903730831/variation-images' << $$$
2020-11-13 11:39:45.806 DEBUG 8076 --- [eb-scheduling-1] jdk.event.security                       :  TLSHandshake: openapi.etsy.com:443, TLSv1.2, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, -114612200
2020-11-13 11:39:45.807 DEBUG 8076 --- [eb-scheduling-1] s.n.www.protocol.http.HttpURLConnection  : sun.net.www.MessageHeader@509c328d9 pairs: {POST /v2/listings/903730831/variation-images HTTP/1.1: null}{Accept-Encoding: gzip}{Authorization: OAuth oauth_consumer_key="h4apln887fo0e0c3nq18noxo", oauth_nonce="4ea0876dffcea0e", oauth_signature="pIg059plqUWHIj3Lly6cECfU4TQ%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1605267585", oauth_token="6da24e5597a09070ac1d8ae392cbf6"}{User-Agent: Google-HTTP-Java-Client/1.34.2 (gzip)}{Content-Type: application/x-www-form-urlencoded; charset=UTF-8}{Host: openapi.etsy.com}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}{Content-Length: 21}
2020-11-13 11:39:45.808  INFO 8076 --- [eb-scheduling-1] c.google.api.client.http.HttpTransport   : Total: 21 bytes
2020-11-13 11:39:45.808  INFO 8076 --- [eb-scheduling-1] c.google.api.client.http.HttpTransport   : variation_images=null
2020-11-13 11:39:46.045 DEBUG 8076 --- [eb-scheduling-1] s.n.www.protocol.http.HttpURLConnection  : sun.net.www.MessageHeader@7fdbb34d14 pairs: {null: HTTP/1.1 400 Bad Request}{Server: Apache}{X-CLOUD-TRACE-CONTEXT: ad3253f8634a0b0ab4740bd2d3564ac8/17368357534886447;o=0}{X-Etsy-Request-Uuid: Eu1Fk-Fgo4UImUDbxu-B-h9Ichac}{X-RateLimit-Limit: 10000}{X-RateLimit-Remaining: 9557}{X-Error-Detail: Value for variation_images was not a valid JSON string.}{Cache-Control: private}{Content-Length: 55}{Content-Type: text/plain;charset=UTF-8}{Date: Fri, 13 Nov 2020 11:39:46 GMT}{Connection: close}{Set-Cookie: uaid=20EZLo8lZ9BPYwv4_4v-pS7udsxjZACC-HUFTTC6Wqk0MTNFyUrJKSsw3djAO9M10KWqwMkovDDPyyfdxTHNr8woTamWAQA.; expires=Sat, 13-Nov-2021 11:39:46 GMT; Max-Age=31536000; path=/; domain=.etsy.com; secure; SameSite=None}{Set-Cookie: user_prefs=jcW0hUP4YD9dXGLUdpwPGry9DWhjZACC-HUFTTA6Oq80J0eHPCKWAQA.; expires=Sat, 13-Nov-2021 11:39:46 GMT; Max-Age=31536000; path=/; domain=.etsy.com}
2020-11-13 11:39:46.046  INFO 8076 --- [eb-scheduling-1] c.google.api.client.http.HttpTransport   : -------------- RESPONSE --------------
HTTP/1.1 400 Bad Request
Server: Apache
X-Error-Detail: Value for variation_images was not a valid JSON string.
Connection: close
X-Etsy-Request-Uuid: Eu1Fk-Fgo4UImUDbxu-B-h9Ichac
Date: Fri, 13 Nov 2020 11:39:46 GMT
X-RateLimit-Remaining: 9557
Cache-Control: private
Set-Cookie: user_prefs=jcW0hUP4YD9dXGLUdpwPGry9DWhjZACC-HUFTTA6Oq80J0eHPCKWAQA.; expires=Sat, 13-Nov-2021 11:39:46 GMT; Max-Age=31536000; path=/; domain=.etsy.com
Set-Cookie: uaid=20EZLo8lZ9BPYwv4_4v-pS7udsxjZACC-HUFTTC6Wqk0MTNFyUrJKSsw3djAO9M10KWqwMkovDDPyyfdxTHNr8woTamWAQA.; expires=Sat, 13-Nov-2021 11:39:46 GMT; Max-Age=31536000; path=/; domain=.etsy.com; secure; SameSite=None
X-RateLimit-Limit: 10000
Content-Length: 55
Content-Type: text/plain;charset=UTF-8
X-CLOUD-TRACE-CONTEXT: ad3253f8634a0b0ab4740bd2d3564ac8/17368357534886447;o=0

2020-11-13 11:39:46.047  INFO 8076 --- [eb-scheduling-1] c.google.api.client.http.HttpTransport   : Total: 55 bytes
2020-11-13 11:39:46.047  INFO 8076 --- [eb-scheduling-1] c.google.api.client.http.HttpTransport   : Value for variation_images was not a valid JSON string.
2020-11-13 11:39:46.048 ERROR 8076 --- [eb-scheduling-1] com.hst.podweb.web.rest.EtsyController   : Etsy request failed.

com.notronix.etsy.api.EtsyAPIException: Etsy request failed.
    at com.notronix.etsy.impl.EtsyDataService.execute(EtsyDataService.java:394)
    at com.notronix.etsy.impl.EtsyDataService.updateVariationImages(EtsyDataService.java:302)
    at com.hst.podweb.web.rest.EtsyController.lambda$uploadImageToListingVariants$1(EtsyController.java:396)
    at java.util.HashMap.forEach(HashMap.java:1289)
    at com.hst.podweb.web.rest.EtsyController.uploadImageToListingVariants(EtsyController.java:394)
    at com.hst.podweb.web.rest.EtsyController.updateVariantToListing(EtsyController.java:345)
    at com.hst.podweb.web.rest.EtsyController.uploadProductToEtsy(EtsyController.java:257)
    at com.hst.podweb.web.rest.EtsyController$$FastClassBySpringCGLIB$$a2b05804.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
    at com.hst.podweb.aop.logging.LoggingAspect.logAround(LoggingAspect.java:102)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
    at com.hst.podweb.web.rest.EtsyController$$EnhancerBySpringCGLIB$$795fc376.uploadProductToEtsy(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
    at java.util.concurrent.FutureTask.run(FutureTask.java)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: com.google.api.client.http.HttpResponseException: 400 Bad Request
Value for variation_images was not a valid JSON string.
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1113)
    at com.notronix.etsy.impl.EtsyDataService.execute(EtsyDataService.java:374)
    ... 45 common frames omitted
cmunden commented 3 years ago

Can you provide more details about the request before it is executed? Place a break point as shown in the image and show the debugger values for the entire request object... (remember to hide any secret keys or tokens in your image). The Content-Length as shown in your data is indicating 21 bytes and I need to see exactly what the 21 bytes of content were. This will help me to debug this issue further.

image

hoanghiep commented 3 years ago

Here is more debug information 1. step1

2. step1-1

3. step2

Gson step2-1

cmunden commented 3 years ago

Very interesting. Gson is failing to serialize your image data. What version of Java are you running in your environment? I am running version 1.8.0_162 and I do not get that same issue.

Execute this statement System.getProperty("java.version"); and see what you get.

hoanghiep commented 3 years ago

My java version is 1.8.0_251

If i use this test script (gson is initialized with default configuration) then i get right value.

        Gson gson = new Gson();
        List<EtsyListingVariationImage> variationImages = new ArrayList<>();
        EtsyListingVariationImage elvi = new EtsyListingVariationImage();
        elvi.setImageId(1l);
        elvi.setPropertyId(2l);
        elvi.setValueId(3l);
        variationImages.add(elvi);
        UrlEncodedContent content = new UrlEncodedContent(Collections.singletonMap("variation_images", gson.toJson(Objects.requireNonNull(variationImages))));
cmunden commented 1 year ago

Version 2 of the API has been turned off. Now moving to Version 3.