{"title":"HttpHeaders.GetValues(Text, Array of [Text]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/httpheaders/httpheaders-getvalues-string-text-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/httpheaders/httpheaders-getvalues-string-text-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/httpheaders/httpheaders-getvalues-string-text-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Gets the values for the specified key.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"HttpHeaders.GetValues(Text, Array of [Text]) Method","slug":"httpheadersgetvaluestext-array-of-text-method","at":0,"chars":3177},{"level":2,"title":"Syntax","slug":"syntax","at":153,"chars":88},{"level":2,"title":"Parameters","slug":"parameters","at":241,"chars":226},{"level":2,"title":"Return Value","slug":"return-value","at":467,"chars":275},{"level":2,"title":"Example","slug":"example","at":742,"chars":2296},{"level":2,"title":"Related information","slug":"related-information","at":3038,"chars":139}],"text":"# HttpHeaders.GetValues(Text, Array of [Text]) Method\n> Version: _Available or changed with runtime version 1.0._\nGets the values for the specified key.\n## Syntax\n```al\n[Ok := ]  HttpHeaders.GetValues(Key: Text, Values: Array of [Text])\n```\n## Parameters\nHttpHeaders\nType: httpheaders-data-type\nAn instance of the httpheaders-data-type data type.\nKey\nType: ../text/text-data-type\nThe specified header.\nValues\nType: ../text/text-data-type\nThe specified header values.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue if the specified header name and values are stored in the collection; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.\n## Example\nThis example demonstrates:\n Adding multiple values to the same header name (Accept header with different MIME types)\n Retrieving header values using the GetValues() method\n Checking the return value to ensure the header exists\n Iterating through the array to process each value\n Practical use case with response headers like Set-Cookie that often have multiple values\n```al\nprocedure ExampleGetValues()\nvar\n    HttpClient: HttpClient;\n    HttpRequestMessage: HttpRequestMessage;\n    HttpResponseMessage: HttpResponseMessage;\n    HttpHeaders: HttpHeaders;\n    HeaderValues: array[10] of Text;\n    HeaderKey: Text;\n    i: Integer;\n    Success: Boolean;\nbegin\n    // Initialize HTTP request\n    HttpRequestMessage.Method := 'GET';\n    HttpRequestMessage.SetRequestUri('https://api.example.com/data');\n\n    // Add multiple values for the same header (for example, Accept header)\n    HttpHeaders := HttpRequestMessage.GetHeaders();\n    HttpHeaders.Add('Accept', 'application/json');\n    HttpHeaders.Add('Accept', 'application/xml');\n    HttpHeaders.Add('Accept', 'text/plain');\n\n    // Get the values for the Accept header\n    HeaderKey := 'Accept';\n    Success := HttpHeaders.GetValues(HeaderKey, HeaderValues);\n\n    if Success then begin\n        Message('Found %1 values for header %2:', ArrayLen(HeaderValues), HeaderKey);\n\n        // Display each value\n        for i := 1 to ArrayLen(HeaderValues) do begin\n            if HeaderValues[i] <> '' then\n                Message('Value %1: %2', i, HeaderValues[i]);\n        end;\n    end else begin\n        Message('Header %1 not found or has no values', HeaderKey);\n    end;\n\n    // Send the request\n    if HttpClient.Send(HttpRequestMessage, HttpResponseMessage) then begin\n        // Process response headers\n        HttpHeaders := HttpResponseMessage.GetHeaders();\n\n        // Check for Set-Cookie headers (servers often send multiple)\n        HeaderKey := 'Set-Cookie';\n        Clear(HeaderValues);\n\n        if HttpHeaders.GetValues(HeaderKey, HeaderValues) then begin\n            Message('Response contains cookies:');\n            for i := 1 to ArrayLen(HeaderValues) do begin\n                if HeaderValues[i] <> '' then\n                    Message('Cookie %1: %2', i, HeaderValues[i]);\n            end;\n        end;\n    end;\nend;\n```\n## Related information\nhttpheaders-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}