phprestcurlups

UPS OAuth 2.0 RESTful API Integration


I'm trying the integrate UPS's new RESTful API that uses OAuth 2.0 and this is the first time I'm doing this. Using the Client ID and Client Secret I'm able to get access token. And to get API services they have a documentation here. In almost all services they are requiring me to pass transactionSrc and transId as parameters in the CURLOPT_HTTPHEADER, for example take this tracking request code example provided below (source link from UPS). Here they made these two parameters required and I have no idea what these two are. I did not find any detail on these two parameters anywhere.

So if anyone knows what these are or can redirect me to some resource that can give some light on this I would very much appreciate it.

/**
 * Requires libcurl
 */

const inquiryNumber = "YOUR_inquiryNumber_PARAMETER";
$query = array(
  "locale" => "en_US",
  "returnMilestones" => "false",
  "returnSignature" => "false"
);

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <YOUR_TOKEN_HERE>",
    "UUID: string",
    "Username: string",
    "isCIE: string",
    "transId: string",
    "transactionSrc: string"
  ],
  CURLOPT_URL => "https://wwwcie.ups.com/api/trackservice/tracking/v1/details/" . inquiryNumber . "?" . http_build_query($query),
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "GET",
]);

$response = curl_exec($curl);
$error = curl_error($curl);

curl_close($curl);

if ($error) {
  echo "cURL Error #:" . $error;
} else {
  echo $response;
}

Solution

  • transId is just a unique Transaction ID that you provide so you can identify a specific request made "An identifier unique to the request. Length 32". Personally I am just generating a guid for this. transactionSrc just the source of this transaction "An identifier of the client/source application that is making the request.Length 512".