Need help integrating SOTI MobiControl into our DevOps pipeline

Solved
T
teddy
ORECO

Hello everyone,

I'm looking to integrate SOTI MobiControl into our DevOps pipeline, specifically aiming to implement CI/CD by uploading an APK file via the POST /packages API. Unfortunately, I've been stuck for several days now and could really use your help.

Here's my current script:


#!/bin/bash

# Fetching the APK
curl -u [USERNAME]:[PASSWORD] -o "/home/[USERNAME]/app_name.apk" "https://nexus.example.com/repository/raw/apk/env_dev/release/app_name.apk"

# Setting base variables
base_url="https://soti.example.com/MobiControl/api"
auth="Basic [BASE64_ENCODED_CREDENTIALS]"
content_type="multipart/related"
content_type2="multipart/related; boundary=content"
apk_path="/home/[USERNAME]/app_name.apk"

# Getting access token
access_token=$(curl -s -X POST "$base_url/token" \
    -H "Authorization: $auth" \
    -H "Content-Type: $content_type" \
    -d "grant_type=password&username=[USERNAME]&password=[PASSWORD]" \
    | jq -r '.access_token')

echo "Access Token: $access_token"

# Sending application download request to MobiControl
curl -X POST "$base_url/packages" \
  -H "Authorization: Bearer $access_token" \
  -H "Content-Type: $content_type2" \
  -d @- <<EOF
--content
Content-Type: application/vnd.android.application.metadata+json

{ "DeviceFamily" : "AndroidPlus", "PackageName": "package", "PackageVersion": "1.0"}
--content
Content-Type: application/vnd.android.application
Content-Disposition: attachment; filename="app_name.apk"
--content--
EOF

However, the server returns the following message: "Internal Server Error".

For your information, I'm using version: 2024.0.1.1020.

Any help would be greatly appreciated!

a year ago
SOTI MobiControl
ANSWERS