DS Server

POST /documentprocessing/barcodes/create

Endpoint

POST https://example.com/documentprocessing/barcodes/create

Description

Creates a barcode image.

Examples

The following example creates a Code128 barcode.

# Request:
curl --location --request POST 'https://trial.dsserver.io/documentprocessing/barcodes/create?barcodeType=code128' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer fePFHv8OtIyRSCAdOnn7USc9kKdYB2rg' \
    --data-raw '{
        "additionalText": "Sets an additional text that is displayed below or above the barcode image",
        "alignment": "BottomCenter",
        "backColor": "#ffffff",
        "foreColor": "#000000",
        "showText": true,
        "text": "Sets the text the barcode should encode.",
        "textAlignment": "Bottom",
        "upperTextLength": 23
    }'

# Result:
"iVBORw0KGgoAAAANSUhEUgAA[..]"

Authorization

This endpoint supports the OAuth authorization method. DS Server checks the access token only when OAuth is enabled in the admin portal (see Enable OAuth). With OAuth disabled, the default of a new installation, the endpoint accepts requests without a token.

DS Server implements OAuth as the authorization method. Two flows are supported:

  • Authorization Code
  • Client Credentials

To use the Client Credentials flow, switch on Allow “Client Credentials” grant type in the security profile (see OAuth Grant Types).

In both cases, a valid access token returned from the OAuth endpoints must be passed in a Bearer Authorization Header, as a Query Parameter or in a Cookie.

Authorization Header

Header fieldDescription
AuthorizationA Bearer authorization header (also called token authentication) contains the OAuth access token. The authorization method and a space i.e. "Bearer " is then put before your valid access token. For example: Authorization: Bearer 4796E23054E64BC773CACBCAF24AD179DE9A3

Query Parameter

Query parameterDescription
access_tokenThe access token is passed directly in the endpoint URL as a query string. For example: ?access_token=4796E23054E64BC773CACBCAF24AD179DE9A3

Cookie

CookieDescription
access_tokenThe access token is passed in a cookie named access_token. For example: Cookie: access_token=4796E23054E64BC773CACBCAF24AD179DE9A3

Request Parameters

NameTypeValueOptional
imageFormatStringA string that specifies the image format of the created barcode. Possible values are: "BMP", "EMF", "GIF", "JPEG", "PNG", "TIFF". Default value is "PNG".yes
barcodeTypeStringA string that specifies the barcode type. Possible values are: "QRCode", "Code128", "EAN13", "UPCA", "EAN8", "Interleaved2of5", "Postnet", "Code39", "AztecCode", "IntelligentMail", "Datamatrix", "PDF417", "MicroPDF", "Codabar", "FourState", "Code11", "Code93", "PLANET", "RoyalMail", "Maxicode".yes
widthintSpecifies the width of the barcode image. Default value is 200.yes
heightintSpecifies the height of the barcode image. Default value is 200.yes

Request Payload

TypeValue
BarcodeThe Barcode object contains the settings for the requested barcode.

Barcode

NameTypeValueOptional
imageFormatStringThe image format.yes
additionalTextStringSpecifies additional text that is rendered with the barcode.yes
alignmentStringThe alignment of the barcode. Possible values are: "TopLeft", "TopCenter", "TopRight", "MiddleLeft", "MiddleCenter", "MiddleRight", "BottomCenter", "BottomLeft", "BottomRight".yes
angleIntegerSpecifies the rotation angle of the barcode image.yes
backColorStringSpecifies the background color of the barcode image.yes
barcodeTypeStringA string that specifies the barcode type. Possible values are: "QRCode", "Code128", "EAN13", "UPCA", "EAN8", "Interleaved2of5", "Postnet", "Code39", "AztecCode", "IntelligentMail", "Datamatrix", "PDF417", "MicroPDF", "Codabar", "FourState", "Code11", "Code93", "PLANET", "RoyalMail", "Maxicode".yes
foreColorStringSpecifies the foreground color of the barcode image.yes
showTextBooleanSpecifies whether to render the text.yes
textStringSpecifies the actual data that is encoded in the barcode.no
textAlignmentStringA string that specifies the position of the text. Possible values are: "Bottom", "Top".yes
upperTextLengthIntegerSpecifies the upper text length of the barcode.yes
heightIntegerSpecifies the height of the barcode.yes
widthIntegerSpecifies the width of the barcode.yes

Success Response

StatusDescription
200On success, the HTTP status code in the response header is 200 (OK). The response body contains the created barcode image encoded as a Base64 encoded string.

Error Response

StatusDescription
401A 401 (Unauthorized) with an empty body is returned, if OAuth is enabled and the request has no valid access token.
400A 400 (Bad Request) is returned, if the body can't be read as a Barcode object or a query parameter has a value of the wrong type, for example width=abc. The body is a problem details object (application/json) with the title "One or more validation errors occurred." and the message per field in errors. This check comes before the license check.
415A 415 (Unsupported Media Type) is returned, if the Content-Type header of a request with a body is not application/json.
405A 405 (Method Not Allowed) with an empty body and the header Allow: POST is returned for any other HTTP method, for example GET.
400A 400 (Bad Request) is returned, if DS Server is not licensed or the license is invalid. On a server that is not registered, the body is the JSON string "DS Server is not registered." (application/json). DS Server checks the license before the parameter values, but after it has read the body and the typed query parameters.
400A 400 (Bad Request) is returned, if no data is found in the body.