salesforce-marketingcloud / FuelSDK-Java

Salesforce Marketing Cloud Java SDK
BSD 3-Clause "New" or "Revised" License
72 stars 123 forks source link

[BUG] Issue updating ETAsset using client.update() #118

Open lgarciaruiz opened 4 years ago

lgarciaruiz commented 4 years ago

Describe the bug Error invoking update method for ETAsset

To Reproduce Retrieve an ETAsset > set content using setContent() > attempt to update the asset in SFMC using client.update(asset);

Expected behavior Expectation was for asset in SFMC to have the updated content

Stack Trace Exception in thread "main" com.exacttarget.fuelsdk.ETSdkException: error invoking update method for type class com.exacttarget.fuelsdk.ETAsset at com.exacttarget.fuelsdk.ETClient.createUpdateDelete(ETClient.java:1101) at com.exacttarget.fuelsdk.ETClient.update(ETClient.java:940) at Package.Test.updateAssetByID(Test.java:91) at Package.Test.main(Test.java:48) Caused by: java.lang.reflect.InvocationTargetException 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 com.exacttarget.fuelsdk.ETClient.createUpdateDelete(ETClient.java:1099) ... 3 more Caused by: com.exacttarget.fuelsdk.ETSdkException: error setting request method: PATCH at com.exacttarget.fuelsdk.ETRestConnection.sendRequest(ETRestConnection.java:246) at com.exacttarget.fuelsdk.ETRestConnection.sendRequest(ETRestConnection.java:223) at com.exacttarget.fuelsdk.ETRestConnection.patch(ETRestConnection.java:161) at com.exacttarget.fuelsdk.ETRestObject.createUpdateDelete(ETRestObject.java:408) at com.exacttarget.fuelsdk.ETRestObject.update(ETRestObject.java:310) ... 8 more Caused by: java.net.ProtocolException: Invalid HTTP method: PATCH at java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:440) at sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(HttpURLConnection.java:553) at sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestMethod(HttpsURLConnectionImpl.java:388) at com.exacttarget.fuelsdk.ETRestConnection.sendRequest(ETRestConnection.java:244) ... 12 more

Code snippet public static void main (String[] args) throws ETSdkException { ETClient client = new ETClient(); ETAsset asset = client.retrieveObject(ETAsset.class, "id=" + assetID); asset.setContent("new text"); ETResponse response = client.update(asset);
for (ETResult result : response.getResults()) { System.out.println(result); } }

Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (e.g. gif) is not sufficient.

Environment

The bug has the severity

Additional context Add any other context about the problem here.