diff --git a/pom.xml b/pom.xml
index 94963c72..81a0d736 100644
--- a/pom.xml
+++ b/pom.xml
@@ -173,6 +173,12 @@
1.7.0
+
+ org.apache.maven
+ maven-model
+ 3.9.5
+
+
diff --git a/src/main/java/com/coveo/pushapiclient/PlatformClient.java b/src/main/java/com/coveo/pushapiclient/PlatformClient.java
index 9d2c665b..22a2d067 100644
--- a/src/main/java/com/coveo/pushapiclient/PlatformClient.java
+++ b/src/main/java/com/coveo/pushapiclient/PlatformClient.java
@@ -2,6 +2,7 @@
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
+import java.io.FileReader;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
@@ -11,6 +12,8 @@
import java.util.HashMap;
import java.util.stream.Stream;
import org.apache.logging.log4j.LogManager;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
/** PlatformClient handles network requests to the Coveo platform */
public class PlatformClient {
@@ -567,7 +570,23 @@ private String[] getAuthorizationHeader() {
}
private String[] getContentTypeApplicationJSONHeader() {
- return new String[] {"Content-Type", "application/json", "Accept", "application/json"};
+ MavenXpp3Reader reader = new MavenXpp3Reader();
+ String version = "";
+ try {
+ Model model = reader.read(new FileReader("pom.xml"));
+ version = model.getVersion();
+ } catch (Exception e) {
+ version = "Not-Available";
+ }
+
+ return new String[] {
+ "Content-Type",
+ "application/json",
+ "Accept",
+ "application/json",
+ "User-Agent",
+ String.format("CoveoSDKJava/%s", version)
+ };
}
private String[] getAes256Header() {