---
title: "HttpClient (_HttpClient class)"
canonical: "https://docs.cuesystem.com/space/CVCHELP/520486913/HttpClient%20(_HttpClient%20class)"
format: markdown
---
> Macro (toc)

---


# HttpClient channels limits

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

# HttpCopy

The command sends HTTP COPY request to the server. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

#### Syntax 

```visualbasic
Function HttpCopy( 
  url As Text, 
  destinationurl As Text, 
  overwrite As Boolean, 
  ByRef responsestatuscode As Long, 
  Optional responseheader As AddressOf ByteString := Nothing) 
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. url of source endpoint. 

destinationurl 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. url of the destination endpoint. 

overwrite 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>. It True **Overwrite: T** header item is added to the Http header otherwise **Overwrite: F **is added. 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

**True** on success 

**False** if an error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88,](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u>  

#### Example 

```visualbasic
Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var responseheader As ByteString[2000] 
  Var responsebody As ByteString[1000] 

  HttpClient1.SetServer("www.anyserver.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 

  If HttpClient1.HttpCopy("copyendpoint/srcdata","copyendpoint/enddata", True, responsestatuscode) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If
End Process
```

# HttpDelete

The command sends an HTTP DELETE request to the server. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

#### Syntax 

```visualbasic
Function HttpDelete( 
  url As Text, 
  ByRef responsestatuscode As Long, 
  Optional responsebody As AddressOf ByteString := Nothing, 
  Optional responseheader As AddressOf ByteString := Nothing) 
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responsebody 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response body. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

**True** on success 

**False** if an error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u>

#### Example 

```visualbasic
Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var responseheader As ByteString[2000] 
  Var responsebody As ByteString[1000] 

  HttpClient1.SetServer("www.anyserver.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 
  If HttpClient1.HttpDelete("api/deleteitem?id=123", responsestatuscode,responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
      If lasterror = 283 Then 
        // Check HTTP response status code 
        DebugPrint(responsestatuscode,responsebody,responseheader) 
        Select responsestatuscode  
          Case 404 // HTTP 404 not found 
          Case 401 // HTTP 401 Unauthorized  
        End Select  
      Else 
        // Check other error  
        Select lasterror 
        End Select 
      End If 
  End If 
End Process
```

# HttpGet

The command sends HTTP GET request to the server. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. If url contains query parameters it must be encoded [https://en.wikipedia.org/wiki/Query_string](https://en.wikipedia.org/wiki/Query_string) . You can use the command EncodeURIComponent for encoding query parameters. 

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

#### Syntax 

```visualbasic
Function HttpGet( 
  url As Text, 
  ByRef responsestatuscode As Long, 
  Optional responsebody As AddressOf ByteString := Nothing, 
  Optional responseheader As AddressOf ByteString := Nothing)  
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. If url contains query parameters it must be encoded [https://en.wikipedia.org/wiki/Query_string](https://en.wikipedia.org/wiki/Query_string)  

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responsebody 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response body. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

**True** on success 

**False** if an error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u>

#### Example 

```visualbasic
Var responseheader As ByteString[2000] 
Var responsebody As ByteString[100000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 

  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 
  If HttpClient1.HttpGet("index.html?param1=5&param2=30", responsestatuscode,responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# HttpGetEx

The command sends HTTP GET request to the server. Query parameters are entered in an array and parameter encoding is done automatically by command. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

#### Syntax 

```visualbasic
Function HttpGetEx( 
  url As Text, 
  parameters As Array[] As _HttpQueryParameter, 
  ByRef responsestatuscode As Long, 
  Optional responsebody As AddressOf ByteString := Nothing, 
  Optional responseheader As AddressOf ByteString := Nothing)  
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. Url cannot contain query parameters.  

parameters 

An array of _HttpQueryParameter. Parameters are encoded and added to url as query parameters automatically. **Attention: parameters values must not be encoded** 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responsebody 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response body. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value* *

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

**True** on success 

**False** if an error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u> 

#### Example 

```visualbasic
Var responseheader As ByteString[2000] 
Var responsebody As ByteString[100000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var queryparameters[2] As _HttpQueryParameter 
  
  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 
  queryparameters[1].name := "param1"  
  queryparameters[1].val := "235" 
  queryparameters[2].name := "param2" 
  queryparameters[2].val := "valueščřřščř" 
  
  If HttpClient1.HttpGetEx("index.html", queryparameters, responsestatuscode,responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# HttpGetToFile

The command sends HTTP GET request to the server. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. If url contains query parameters it must be encoded [https://en.wikipedia.org/wiki/Query_string](https://en.wikipedia.org/wiki/Query_string) . You can use the command EncodeURIComponent for encoding query parameters.  The function saves response body into specified file.

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

> ℹ️ This function is supported since firmware 21.70

#### Syntax 

```visualbasic
Function HttpGetToFile( 
  url As Text, 
  ByRef responsestatuscode As Long, 
  filename As Text, 
  Optional responseheader As AddressOf ByteString := Nothing)  
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. If url contains query parameters it must be encoded [https://en.wikipedia.org/wiki/Query_string](https://en.wikipedia.org/wiki/Query_string)  

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

filename

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>.  It is the filename for repsonse body. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

**True** on success 

**False** if an error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u>

#### Example 

```visualbasic
Var responseheader As ByteString[2000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 

  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 
  If HttpClient1.HttpGetToFile("index.html?param1=5&param2=30", responsestatuscode,"/filestorage/data.txt",responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# HttpHead

The command sends HTTP HEAD request to the server. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. If url contains query parameters it must be encoded [https://en.wikipedia.org/wiki/Query_string](https://en.wikipedia.org/wiki/Query_string) . You can use the command EncodeURIComponent for encoding query parameters. 

#### Syntax 

```visualbasic
Function HttpHead( 
  url As Text, 
  ByRef responsestatuscode As Long, 
  Optional responseheader As AddressOf ByteString := Nothing)  
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. If url contains query parameters it must be encoded [https://en.wikipedia.org/wiki/Query_string](https://en.wikipedia.org/wiki/Query_string)  

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

**True** on success 

**False** if an error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u>

#### Example 

```visualbasic
Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var responseheader As ByteString[2000] 

  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 

  If HttpClient1.HttpHead("index.html", responsestatuscode,responseheader) Then 
    DebugPrint(responsestatuscode,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# HttpHeadEx

The command sends HTTP HEAD request to the server. Query parameters are entered in an array and parameter encoding is done automatically by the command. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

#### Syntax 

```visualbasic
Function HttpHeatEx( 
  url As Text, 
  parameters As Array[] As _HttpQueryParameter, 
  ByRef responsestatuscode As Long, 
  Optional responseheader As AddressOf ByteString := Nothing)  
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. 

parameters 

An array of _HttpQueryParameter. Parameters are encoded and added to url as query parameters automatically. **Attention: parameters values must not be encoded** 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

**True** on success 

**False** if an error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u>

#### Example 

```visualbasic
Var responseheader As ByteString[2000] 
Var responsebody As ByteString[100000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var queryparameters[2] As _HttpQueryParameter 

  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 
  queryparameters[1].name := "param1"  
  queryparameters[1].val := "235" 
  queryparameters[2].name := "param2" 
  queryparameters[2].val := "valueščřřščř" 

  If HttpClient1.HttpHeadEx("index.html", queryparameters, responsestatuscode,responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found  
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# HttpOptions

The command sends an HTTP OPTIONS request to the server. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

#### Syntax 

```visualbasic
Function HttpOptions( 
  url As Text, 
  ByRef responsestatuscode As Long, 
  Optional responsebody As AddressOf ByteString := Nothing, 
  Optional responseheader As AddressOf ByteString := Nothing) 
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responsebody 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response body. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. , 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

***True*** on success 

***False*** some error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number, , that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u> 

#### Example 

```visualbasic
Var responsebody As ByteString[20000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var responseheader As ByteString[2000] 

  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 

  If HttpClient1.HttpOptions("index.html", responsestatuscode, responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# HttpPatch

The command sends an HTTP PATCH request to the server. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

#### Syntax 

```visualbasic
Function HttpPatch( 
  url As Text,  
  contenttype As ByteString, 
  body As ByteString, 
  ByRef responsestatuscode As Long, 
  Optional responsebody As AddressOf ByteString := Nothing, 
  Optional responseheader As AddressOf ByteString := Nothing) 
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. 

contenttype 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> content of Content-Type HTTP header item. For example  &S"application/xml; charset=UTF-8" 

body 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> the body of the request. 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responsebody 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response body. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

***True*** on success 

***False*** some error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u>, <u>[285](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#285)</u> 

#### Example 

```visualbasic
Var responsebody As ByteString[20000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var responseheader As ByteString[2000] 

  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 

  If HttpClient1.HttpPatch("index.html", &S"text/plain",&S"MyBodyText",responsestatuscode, responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# HttpPost

The command sends an HTTP POST request to the server. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

#### Syntax 

```visualbasic
Function HttpPost( 
  url As Text, 
  contenttype As ByteString, 
  body As ByteString, 
  ByRef responsestatuscode As Long, 
  Optional responsebody As AddressOf ByteString := Nothing, 
  Optional responseheader As AddressOf ByteString := Nothing) 
As Boolean
```

#### Parameters 

method 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is the Http method name. 

contenttype 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> content of Content-Type HTTP header item. For example  &S"application/xml; charset=UTF-8" 

body 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> the body of the request. 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responsebody 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response body. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

***True*** on success 

***False*** some error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u>, <u>[285](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#285)</u> 

#### Example 

```visualbasic
Var responsebody As ByteString[20000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var responseheader As ByteString[2000] 

  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 

  If HttpClient1.HttpPost("index.html", &S"text/plain",&S"MyBodyText",responsestatuscode, responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# HttpPostFormWWWURLEncoded

The command sends an HTTP POST request to the server with content type **application/www-x-form-urlencoded**. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

#### Syntax* *

```visualbasic
Function HttpPostFormWWWURLEncoded( 
  url As Text, 
  parameters As Array[] As _HttpQueryParameter, 
  ByRef responsestatuscode As Long, 
  Optional responsebody As AddressOf ByteString := Nothing, 
  Optional responseheader As AddressOf ByteString := Nothing) 
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. 

parameters 

An array of _HttpQueryParameter. Parameters are encoded and inserted into the body of posted Http Post request automatically. **Attention: parameters values must not be encoded** 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responsebody 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response body. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

***True*** on success 

***False*** some error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u> 

#### Example 

```visualbasic
Var responseheader As ByteString[2000] 
Var responsebody As ByteString[100000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var queryparameters[2] As _HttpQueryParameter 

  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 
  queryparameters[1].name := "param1"  
  queryparameters[1].val := "235" 
  queryparameters[2].name := "param2" 
  queryparameters[2].val := "valueščřřščř" 
  If HttpClient1.HttpPostFormWWWURLEncoded("index.html", queryparameters, responsestatuscode,responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found  
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# HttpPostJSON

The command sends an HTTP POST request to the server with content type **application/json; charset=UTF-8**. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

#### Syntax 

```visualbasic
Function HttpPostJSON( 
  url As Text, 
  json As Text, 
  ByRef responsestatuscode As Long, 
  Optional responsebody As AddressOf ByteString := Nothing, 
  Optional responseheader As AddressOf ByteString := Nothing) 
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. 

json 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>.  body of the request. You can use FormatJSON to create JSON. 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responsebody 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response body. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

***True*** on success 

***False*** some error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u>

#### Example 

```visualbasic
Structure MyJSON 
  Var a As Long 
  Var b As Text[100] 
End Structure  

Var responsebody As ByteString[20000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var responseheader As ByteString[2000] 
  Var body As Text[100] 
  Var data As MyJSON 

  data.a := 1 
  data.b := "textdata" 
  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 
  FormatJSON(data,body)  
  If HttpClient1.HttpPostJSON("index.html", body, responsestatuscode, responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# HttpPostJSONInUTF8

The command sends an HTTP POST request to the server with content type **application/json; charset=UTF-8**. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

**This function is available since firmware 20.00**

#### Syntax 

```visualbasic
Function HttpPostJSON( 
  url As Text, 
  jsoninutf8 As ByteString, 
  ByRef responsestatuscode As Long, 
  Optional responsebody As AddressOf ByteString := Nothing, 
  Optional responseheader As AddressOf ByteString := Nothing) 
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. 

jsoninutf8

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u><u> </u>.  body of the request. You can use FormatJSON to create JSON. 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responsebody 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response body. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

***True*** on success 

***False*** some error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u>

#### Example 

```visualbasic
Structure MyJSON 
  Var a As Long 
  Var b As Text[100] 
End Structure  

Var responsebody As ByteString[20000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var responseheader As ByteString[2000] 
  Var body As ByteString[100] 
  Var data As MyJSON 

  data.a := 1 
  data.b := "textdata" 
  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 
  FormatJSON(data,body)  
  If HttpClient1.HttpPostJSONInUTF8("index.html", body, responsestatuscode, responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# HttpPut

The command sends an HTTP PUT request to the server. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

#### Syntax 

```visualbasic
Function HttpPut( 
  url As Text, 
  contenttype As ByteString, 
  body As ByteString, 
  ByRef responsestatuscode As Long, 
  Optional responseheader As AddressOf ByteString := Nothing) 
As Boolean
```

#### Parameters 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. 

contenttype 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> content of Content-Type HTTP header item. For example &S"application/xml; charset=UTF-8" 

body 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> the body of the request. 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> 

***True*** on success 

***False*** some error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u>

#### Example 

```visualbasic
Var responsebody As ByteString[20000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var responseheader As ByteString[2000] 

  HttpClient1.SetServer("www.google.com" , 443, True) 
  HttpClient1.SetTimeout(:10) 
  If HttpClient1.HttpPut("index.html", &S"text/plain",&S"MyBodyText",responsestatuscode,responseheader) Then 
    DebugPrint(responsestatuscode,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
        End Select 
    End If 
  End If 
End Process
```

# HttpRequest

The command sends any HTTP request to the server. This command could be used if any special Http commands are not suitable. The command supports cookies, basic authentication, digest authentication, and HTTP redirection. 

[https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585/CUE+System+limits#HttpClient-channels) 

#### Syntax 

```visualbasic
Function HttpRequest( 
  method As Text, 
  url As Text, 
  addheader As ByteString, 
  body As ByteString, 
  ByRef responsestatuscode As Long, 
  Optional responsebody As AddressOf ByteString := Nothing, 
  Optional responseheader As AddressOf ByteString := Nothing) 
As Boolean
```

#### Parameters 

method 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It Http method name. 

url 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u>. endpoint url. 

addheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u>. add more header items to the Http header. If you want to add more header items there must be \0D\0A  (CRLF) between them.   

Notice: Please do not add content-length header item. This header item is added automatically.

body 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> the body of the request. 

responsestatuscode 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is Http response status code. 

responsebody 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response body. 

responseheader 

<u>[ByteString](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#ByteString)</u> Optional. It is the Http response header. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

***True*** on success 

***False*** some error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[88](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#88)</u> <u>[92](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[94](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[278](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#278)</u>, <u>[283](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#283)</u>, <u>[284](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#284)</u><u>,</u> <u>[285](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#285)</u>

#### Example 

```visualbasic
Var responsebody As ByteString[20000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var responseheader As ByteString[2000] 

  HttpClient1.SetServer("www.google.com", 443, True) 
  HttpClient1.SetTimeout(:10) 
  If HttpClient1.HttpRequest("GET", "index.html", &S"Content-Type: application/javascript\0D\0AOtherItem: xyz",&S"function xyz(){}",responsestatuscode, responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```


#### Example of using Authorization: Bearer

```visualbasic
Var responsebody As ByteString[20000] 

Private Process Autoexec() 
  Var responsestatuscode As Long := 0 
  Var lasterror As Long := 0 
  Var responseheader As ByteString[2000] 

  HttpClient1.SetServer("www.google.com", 443, True) 
  HttpClient1.SetTimeout(:10) 
  If HttpClient1.HttpRequest("GET", "index.html", &S"Authorization: Bearer xyz12548abcdfgteq\0D\0AContent-Type: application/javascript",&S"function xyz(){}",responsestatuscode, responsebody,responseheader) Then 
    DebugPrint(responsestatuscode,responsebody,responseheader) 
  Else 
    // optional error analysis 
    lasterror := GetLastError() 
    If lasterror = 283 Then 
      // Check HTTP response status code 
      DebugPrint(responsestatuscode,responsebody,responseheader) 
      Select responsestatuscode  
        Case 404 // HTTP 404 not found 
        Case 401 // HTTP 401 Unauthorized  
      End Select  
    Else 
      // Check other error  
      Select lasterror 
      End Select 
    End If 
  End If 
End Process
```

# SetAuthentication  

This command sets authentication parameters for Http requests if server requires **Basic **or **Digest **authentication. 

> ℹ️ If server requires Bearer authentication it is necessary to use HttpRequest command and add HTTP header item Authorization: Bearer <token> . You can find example at HttpRequest command (Example of using Authorization: Bearer)

#### Syntax 

Firmware up to version 20.10

```visualbasic
Function SetAuthentication( 
  username As Text, 
  password As Text) 
As Boolean
```


Firmware since version 20.20

```visualbasic
Function SetAuthentication( 
  username As Text, 
  password As Text,
  Optional sendbasicauthenticationdirectly As Boolean:= False) 
As Boolean
```


#### Parameters 

username 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is the username. 

password 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is the password. 

sendbasicauthenticationdirectly

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>. It is optional parameter, default value is False. **This parameter is available since firmware 20.20.  **If True, the basic authorization is sent directly, in the HTTP header, without asking which authorization the HTTP server requires.  This is required by some devices (for example Maevex by Matrix)


#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>  

***True*** on success 

***False*** some error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[281](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#281)</u> 

#### Example 

```
HttpClient1.SetAuthentication("john","mypassword")
```

# SetServer

The function sets a server parameter. This command **must be called** before calling any Http request. This command clears all cookies in the session if the session is enabled.  

#### Syntax 

```visualbasic
Function SetServer ( 
  address As Text, 
  Optional port As Long := 80, 
  Optional usehttps As Boolean := False, 
  Optional checkservercertificate As Boolean := False) 
As Boolean
```

#### Parameters 

address 

<u>[Text](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is the server IP address or server domain name. 

port 

<u>[Long](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It TCP port. The default value is 80.  

usehttps 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>. If it is True the encrypted HTTPS protocol is used. TLS 1.1, TLS 1.2, and TLS 1.3 are supported. 

checkservercertificate 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>. If it is True the server HTTPS certificate is checked. The certificate must be valid and signed by a trusted CA. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> 

***True*** on success 

***False*** some error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[281](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#281)</u> 

#### Example 

```
HttpClient1.SetServer("www.gogle.com", 443, True, True)
```

# SetSession

The function enables/disable session in a channel. Session includes a set of cookies that have been set by the HTTP server when an HTTP request is made. If the session is enabled, the HTTPclient channel remembers the set of cookies between HTTP requests.  

#### **Firmware 15.00 or later is required.** 

#### Syntax 

```visualbasic
Function SetSession(enable As Boolean) As Boolean
```

#### Parameters 

enable 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u>. If parameter enable is True 

Clear all cookies from the previous session. Then command enables the session. 

If the parameter enables is False  

Clear all cookies from the previous session. Then the command disables the session. 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> 

***True*** on success 

***False*** some error occurs.  

#### Example 

```visualbasic
HttpClient1.SetSession(True)
```

# SetTimeout

The command sets a timeout for Http requests. When the application starts, the timeout is set to 10 seconds automatically. It is not necessary to call this function if this timeout is satisfactory. 

#### Syntax 

```visualbasic
Function SetTimeout(timeout As Time) As Boolean
```

#### Parameters 

timeout 

<u>[Time](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time)</u> timeout for http request. The timeout must be in the range of 0.001s to 3600s 

#### Return value 

<u>[Boolean](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> 

***True*** on success 

***False*** some error occurs. A function <u>[GetLastError](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The following errors may occur: <u>[280](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510525445/Command+errors#280)</u> 

# Structure _HttpQueryParameter

The structure for for storing the name and value of the query parameter

```visualbasic
Global Structure _HttpQueryParameter  
  Var name As Text[50] 
  Var val As Text[200] 
End Structure
```