FuelSDK-Java icon indicating copy to clipboard operation
FuelSDK-Java copied to clipboard

No enum constant com.exacttarget.fuelsdk.ETEmail.Type.Normal

Open dleppik opened this issue 8 years ago • 7 comments

When retrieving email, I get an exception as it tries to instantiate an ETEmail and doesn't find ETEmail.Type.Normal.

Sample code (Scala):

import com.exacttarget.fuelsdk.{ETEmail, ETResponse, ETFilter, ETClient}

object Sample extends App {
  val filename = "/path/to/fuelsdk.properties"
  val client = new ETClient(filename)
  client.retrieve(classOf[ETEmail], new ETFilter)
}

Stack trace:

Exception in thread "main" com.exacttarget.fuelsdk.ETSdkException: error invoking retrieve method for type class com.exacttarget.fuelsdk.ETEmail
    at com.exacttarget.fuelsdk.ETClient.retrieve(ETClient.java:425)
    at com.exacttarget.fuelsdk.ETClient.retrieve(ETClient.java:373)
    at Sample$.delayedEndpoint$Sample$1(Sample.scala:8)
    at Sample$delayedInit$body.apply(Sample.scala:4)
    at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
    at scala.App$class.main(App.scala:76)
    at Sample$.main(Sample.scala:4)
    at Sample.main(Sample.scala)
    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:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
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:497)
    at com.exacttarget.fuelsdk.ETClient.retrieve(ETClient.java:418)
    ... 17 more
Caused by: com.exacttarget.fuelsdk.ETSdkException: could not set property "type" of object com.exacttarget.fuelsdk.ETEmail[
    id = 9029
    key = FF9E9FBA-2073-4221-8A85-AC8BA0BFD6F2
    name = Welcome
    createdDate = Fri Oct 02 14:38:53 CDT 2015
    modifiedDate = Fri Oct 02 15:38:10 CDT 2015
    folderId = 57549
    subject = Salesforce Marketing test for %%fullname%%
    htmlBody = <html>
<body>
<p>
  Hello, %%firstname%%!  This was scheduled to be sent at 5pm on Friday afternoon.
</p>
<small>
  <p>This email was sent by:</p>
  <p>
    %%Member_Busname%%
    <br />
    %%Member_Addr%%
    <br />
    %%Member_City%%, %%Member_State%% %%Member_PostalCode%%
    <br />
    %%Member_Country%%
  </p>
  <a href="%%profile_center_url%%">Profile Center</a>
</small>
<custom name="opencounter" type="tracking">
</body>
</html>
    textBody = 
    isHtmlPaste = true
]
    at com.exacttarget.fuelsdk.ETSoapObject.fromInternal(ETSoapObject.java:966)
    at com.exacttarget.fuelsdk.ETSoapObject.retrieve(ETSoapObject.java:335)
    at com.exacttarget.fuelsdk.ETSoapObject.retrieve(ETSoapObject.java:149)
    at com.exacttarget.fuelsdk.ETSoapObject.retrieve(ETSoapObject.java:131)
    ... 22 more
Caused by: java.lang.IllegalArgumentException: No enum constant com.exacttarget.fuelsdk.ETEmail.Type.Normal
    at java.lang.Enum.valueOf(Enum.java:238)
    at com.exacttarget.fuelsdk.ETSoapObject$EnumConverter.convert(ETSoapObject.java:860)
    at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:491)
    at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1000)
    at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:454)
    at com.exacttarget.fuelsdk.ETSoapObject.fromInternal(ETSoapObject.java:962)
    ... 25 more

dleppik avatar Oct 06 '15 19:10 dleppik

Yep, I am getting the same problem. It looks like the Normal constant is indeed nonexistent, there are only HTML and TEXT, in the ETEmail class source:

public enum Type {
    HTML("HTML"),
    TEXT("Text");
    private final String value;

    Type(String value) {
        this.value = value;
    }

    public String value() {
        return value;
    }
}

diogovernier avatar Nov 10 '15 22:11 diogovernier

Same here, I did more tracing though . It looks like the responses coming back contain emailType=Normal, which causes the exception when trying to set the type property in the ETEmail (ETSoapObject:962) since type property enum only know "HTML", and "Text" as @diogovernier mentioned in his comment.

I would say that there was an update in the soap service that was not followed in the Fule SDK leading to outdated ETEmail.Type.

I will do the changes and try if every thing worked will do a pull request.

ka-sh avatar Jan 11 '16 10:01 ka-sh

What the hell is a Normal EmailType vs. the alternatives?

devinus avatar Jan 28 '16 06:01 devinus

This affects our project as well. Do you have a solution for this, or a workaround?

avelinsk avatar Dec 02 '16 12:12 avelinsk

Hi Avelinsk, I kinda forgot the details of this issue and as you can see there not much of activity here, however, I remember that I had to add another type in an Enum Type and it worked perfectly fine. If you traced the issue using debugger you will be able to resolve it easly, I am sorry If I can't remember any more details to help out.

ka-sh avatar Dec 28 '16 03:12 ka-sh

hi ka-sh, thanks for your answer. I fixed this problem by patching the FuelSDK. But this is only a workaround. I would be happy to have an official FuelSDK release, where this issue has been fixed.

avelinsk avatar Dec 29 '16 13:12 avelinsk

I'm getting this same issue now, but with the enum missing "Text Only" Caused by: java.lang.IllegalArgumentException: No enum constant com.exacttarget.fuelsdk.ETEmail.Type.Text Only

Which I don't wee a way to quick patch, as it's not really possible to have an enum have a space in it, is it?

SiggiVG avatar Jan 10 '18 13:01 SiggiVG