Framing your header in the HTTPHeader parameter

Guidelines for framing your header:

  • If using a header variable, it must be declared as a string and be large enough to hold the contents.

  • The contents of the header variable must be enclosed in quotes.

  • Your header must match exactly what the server expects; don’t take shortcuts.

  • A long header, like an authorization header, will need to be split up on multiple lines and concatenated together into a single variable.

  • If your header needs to include characters, like double quotes or the “-“ minus symbol, they may need to be inserted into the header using the CHR() instruction. Here is a reference:

    Decimal
    #

    ASCII
    Char

     

    Decimal
    #

    ASCII
    Char

     

    Decimal
    #

    ASCII
    Char

    10

    LF

     

    42

    *

     

    64

    @

    13

    CR

     

    43

    +

     

    91

    [

    32

    Space (SP)

     

    44

    ,

     

    92

    \

    33

    !

     

    45

    -

     

    93

    ]

    34

    "

     

    46

    .

     

    94

    ^

    35

    #

     

    47

    /

     

    95

    _

    36

    $

     

    58

    :

     

    96

    `

    37

    %

     

    59

    ;

     

    123

    {

    38

    &

     

    60

    <

     

    124

    |

    39

     ‘

     

    61

    =

     

    125

    }

    40

    (

     

    62

    >

     

    126

    ~

    41

    )

     

    63

    ?

     

     

     

    NOTE:

    Most characters, such as ":", can be inserted into your header or any string without using CHR(). However, characters like double quotes (") and the negative sign (–) must be concatenated. The full list of decimal to ASCII characters is also available in the CRBasic Editor help under “ASCII Codes and Characters.”

    Example:

    The server requires a string of:

    "Authorization: Bearer CjBbMUr0-MUQfNzIyRtn"

    When entered in CRBasic it appears as follows:

     
    httpHeader = "Authorization: Bearer CjBbMUr0-MUQfNzIyRtn"
     

    *Notice the - minus character between CjBbMUr0 and MUQfNzIyRt is blue instead of pink. This indicates a problem in the string.

    To correctly set the minus character as a string, use the following code:

    "Authorization: Bearer CjBbMUr0" & CHR(45) & "MUQfNzIyRtn"

    NOTE:

    The & character is used to concatenate the three pieces together to form the complete string.