1. Introduction
  2. Order Management
  3. Sample Code
  4. Errors and Troubleshooting
  5. Appendix
  6. Print-Friendly Documentation

Sample Code - Reissue Certificate

For the examples below:

Account ID
001007
API Key
n9hq0fp9q63htpmt7xcthztt5n4zx721
Order ID
111222

Using cURL

User creates a JSON string (named data.json for simplicity and formatted for readability):
{
  "server_type":2,
  "csr":"-----BEGIN CERTIFICATE REQUEST-----\n[CSR GOES HERE]\n-----END CERTIFICATE REQUEST-----"
}
User uses curl from the commandline to send the REISSUE request:
curl -u "001007:n9hq0fp9q63htpmt7xcthztt5n4zx721" -X REISSUE \
-H "Content-Type: application/vnd.digicert.rest-v1+json" \
--data @data.json https://api.digicert.com/order/111222

Using C#

using System;
using System.Text;
using System.Net;
using System.IO;

namespace ConsoleApplication1
{
  class Program
  {
    static void Main(string[] args)
    {
      string post_data = @"{
""server_type"":2,
""csr"":""-----BEGIN CERTIFICATE REQUEST-----\n[CSR GOES HERE]\n-----END CERTIFICATE REQUEST-----""
      }";

      byte[] postBytes = Encoding.UTF8.GetBytes(post_data);
      string uri = "https://api.digicert.com/order/111222";

      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
      request.KeepAlive = false;
      request.ProtocolVersion = HttpVersion.Version10;
      request.Method = "REISSUE";
      request.UserAgent = "DigiCertAPIClient/0.1";
      request.ContentType = "application/vnd.digicert.rest-v1+json";
      request.ContentLength = postBytes.Length;
      request.Headers.Add("Authorization", "Basic " + GetEncodedCredential());

      try
      {
        Stream requestStream = request.GetRequestStream();
        requestStream.Write(postBytes, 0, postBytes.Length);
        requestStream.Close();

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();//throws WebException
        Console.WriteLine(new StreamReader(response.GetResponseStream()).ReadToEnd());
      }
      catch (WebException e)
      {
        Console.WriteLine(e.Message);
      }
    }

    static private String GetEncodedCredential()
    {
      return Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("001007" + ":" + "n9hq0fp9q63htpmt7xcthztt5n4zx721"));
    }
  }
}

Using PHP


$arr = array(
"server_type" => 2,
"csr" => "-----BEGIN CERTIFICATE REQUEST-----\n[CSR GOES HERE]\n-----END CERTIFICATE REQUEST-----");

$json = json_encode($arr);
$headers = array(
'Content-Type: application/vnd.digicert.rest-v1+json'
);

$url = 'https://api.digicert.com/order/111222';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, '001007:n9hq0fp9q63htpmt7xcthztt5n4zx721');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'REISSUE');
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

Using Ruby

require 'net/http'
require 'uri'

uri = URI.parse 'https://api.digicert.com/order/111222'

request = Net::HTTP::POST.new uri.request_uri
request.basic_auth('001007','n9hq0fp9q63htpmt7xcthztt5n4zx721')

request['Content-Type'] = 'application/vnd.digicert.rest-v1+json'
request['X-HTTP-Method-Override'] = 'REISSUE'

#Note that this JSON body is formatted for readability
request.body = <<JSON
{
"server_type":2,
"csr":"-----BEGIN CERTIFICATE REQUEST-----\n[CSR GOES HERE]\n-----END CERTIFICATE REQUEST-----"
}
JSON

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

result = http.request(request)