Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

PI Web API Reference

WebID Encoding (WebID)

Supplied code snippets are using the C# programming language; the exact syntax may differ depending on the programming language used by your client application.

None

If an Encoding Method of None is specified, the verbatim value is represented directly in the WebID.

Urlencoded Bytes

If an Encoding Method of Urlencoded Bytes is specified, then a byte array input is expected, and the output is a URL-safe Base64 string, as specified in RFC 4648 Section 5. Importantly, WebID requires that padding not be used (see RFC 4648 section 3.2).

internal static string Encode(byte[] value)
{
    string encoded = System.Convert.ToBase64String(value);
    return encoded.TrimEnd(new char[] { '=' }).Replace('+', '-').Replace('/', '_');
}

Urlencoded Guid

If an Encoding Method of Urlencoded Guid is specified, then the GUID is converted to a byte array using the CLR's Guid.ToByteArray() or similar, and then encoded using the method described in Urlencoded Bytes. When implementing on non-Microsoft platforms, note that the byte order for a GUID as produced by the CLR, or as defined in Rpcdce.h, is not the same as the byte order for an RFC 4122 UUID. WebID serialization and deserialization requires a Microsoft-style GUID byte array.

internal static string Encode(Guid value)
{
    byte[] bytes = value.ToByteArray();
    return Encode(bytes);
}

Urlencoded Int32

If an Encoding Method of Urlencoded Int32 is specified, then the integer is converted to a little-endian byte array, and then encoded using the method described in Urlencoded Bytes.

internal static string Encode(int value)
{
    byte[] bytes = System.BitConverter.GetBytes(value);
    if (!BitConverter.IsLittleEndian)
    {
        Array.Reverse(bytes);
    }

    return Encode(bytes);
}

Urlencoded UTF8 String

If an Encoding Method of Urlencoded UTF8 String is specified, the String is converted to a UTF-8 byte array, and then encoded using the method described in Urlencoded Bytes.

internal static string Encode(string value)
{
    byte[] bytes = System.Text.Encoding.UTF8.GetBytes(value.ToUpperInvariant());
    return Encode(bytes);
}
TitleResults for “How to create a CRG?”Also Available in