close

NOTE: Currently, Resty v3 is in beta release

DELETE Request#

This page discusses simple DELETE requests. Users can utilize Resty features across nearly all HTTP methods.

  • Explore the documentation to fulfill all use cases.
  • Examples use request-level methods; however, Resty also includes client-level methods to configure settings for all requests.

Examples#

See Request Body Types, Allow Payload On

// create a Resty client
client := resty.New()
defer client.Close()

Simple#

res, err := client.R().
    SetAuthToken("bc594900518b4f7eac75bd37f019e08fbc594900518b4f7eac75bd37f019e08f").
    SetError(&Error{}). // or SetError(Error{}).
    Delete("https://myapp.com/articles/123456")

fmt.Println(err, res)
fmt.Println(res.Error().(*Error))

With Payload#

See Allow Payload On

res, err := client.R().
    SetAuthToken("bc594900518b4f7eac75bd37f019e08fbc594900518b4f7eac75bd37f019e08f").
    SetBody(map[string]any{
        "article_ids": []int{1002, 1006, 1007, 87683, 45432},
    }). // default request content type is JSON
    SetError(&Error{}). // or SetError(Error{}).
    Delete("https://myapp.com/articles")

fmt.Println(err, res)
fmt.Println(res.Error().(*Error))
Copied!