Am calling to Bulk 2.0 API to get the details for Activity Export in java, but am getting the HTTP status code 400 with error response.
URL:https://secure.p03.eloqua.com/API/Bulk/2.0/activities/exports
Input JSON :
{"filter":"'{{Activity.Type}}'='EmailClickthrough' and '{{Activity.CreatedAt}}'>='2014-01-02 11:42:01'","name":"Bulk Activity Export","dataRetentionDuration":"PT1H","fields":{"ActivityId":"{{Activity.Id}}","AssetType":"{{Activity.Asset.Type}}","EmailWebLink":"{{Activity.Field(EmailWebLink)}}","ActivityDate ":"{{Activity.CreatedAt}}","VisitorId":"{{Activity.Visitor.Id}}","ActivityType":"{{Activity.Type}}","IpAddress":"{{Activity.Field(IpAddress)}}","SubjectLine":"{{Activity.Field(SubjectLine)}}","AssetName":"{{Activity.Asset.Name}}","EmailRecipientId":"{{Activity.Field(EmailRecipientId)}}","EmailAddress":"{{Activity.Field(EmailAddress)}}","VisitorExternalId":"{{Activity.Visitor.ExternalId}}","ContactId":"{{Activity.Contact.Id}}","AssetId":"{{Activity.Asset.Id}}"}}
Output :
Status code: 400
Output JSON :
{"failures":[{"field":"fields","stackTrace":[],"value":"ActivityDate ","constraint":"Must start with an alpha or underscore character and can only contain alphanumeric and underscore characters (ie match /^[_a-zA-Z][_0-9a-zA-Z]*$/)."}]}
Here am adding the java code to API call
String _baseUrl ="https://secure.p03.eloqua.com/API/Bulk/2.0/activities/exports"; | |||
String authString = user + ":" + password; | |||
String _authToken = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(authString.getBytes()); |
URL url = new URL(_baseUrl);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(<oracle proxy which i removed>));
HttpURLConnection conn = (HttpURLConnection) url.openConnection(proxy);
conn.setInstanceFollowRedirects(false);
conn.setRequestMethod(method.toString());
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
conn.setConnectTimeout(getConTimeOut()*60*1000); /* 60*1000=> 1 min in milliseconds * number of minutes (max time taken to establish connection) */
conn.setReadTimeout(getConTimeOut()*60*1000); /* the max idle time between connection establishment and the response packet received */
conn.setRequestProperty("Authorization", _authToken);
conn.addRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 5.5; Windows NT 4.0)");
if (method == Method.POST || method == Method.PUT) {
conn.setDoOutput(true);
final OutputStream os = conn.getOutputStream();
os.write(body.getBytes());
os.flush();
os.close();
}
InputStream is = null;
if (conn.getResponseCode() == 200) {
is = conn.getInputStream();
} else {
/* error from server */
is = conn.getErrorStream();
}
However by using above code am able to fetch other API (Rest and Bulk) 1.0 calls, but am not able to get for above Bulk 2.0 API call.