Sha256: 28d0fcd0c27cd37ead44c6ef27015120e47ff52602f06e76c2138832f82e1262

Contents?: true

Size: 1.19 KB

Versions: 35

Compression:

Stored size: 1.19 KB

Contents

# *Flexirest:* Plain requests

If you are already using Flexirest but then want to simply call a normal URL and receive the resulting content as a string (i.e. not going through JSON parsing or instantiating in to a `Flexirest::Base` descendent) you can use code like this:

```ruby
class Person < Flexirest::Base
end

people = Person._plain_request('http://api.example.com/v1/people') # Defaults to get with no parameters
# people is a normal Flexirest object, implementing iteration, HAL loading, etc.

Person._plain_request('http://api.example.com/v1/people', :post, {id:1234,name:"John"}) # Post with parameters
```

The parameters are the same as for `_request`, but it does no parsing on the response

You can also bypass the response parsing using a mapped method like this:

```ruby
class Person < Flexirest::Base
  get :all, "/v1/people", plain: true
end
```

The response of a plain request (from either source) is a `Flexirest::PlainResponse` which acts like a string containing the response's body, but it also has a `_headers` method that returns the HTTP response headers and a `_status` method containing the response's HTTP method.


-----

[< Raw requests](raw-requests.md) | [JSON API >](json-api.md)

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
flexirest-1.8.0 docs/plain-requests.md
flexirest-1.7.9 docs/plain-requests.md
flexirest-1.7.8 docs/plain-requests.md
flexirest-1.7.7 docs/plain-requests.md
flexirest-1.7.6 docs/plain-requests.md
flexirest-1.7.5 docs/plain-requests.md
flexirest-1.7.4 docs/plain-requests.md
flexirest-1.7.3 docs/plain-requests.md
flexirest-1.7.2 docs/plain-requests.md
flexirest-1.7.1 docs/plain-requests.md
flexirest-1.7.0 docs/plain-requests.md
flexirest-1.6.9 docs/plain-requests.md
flexirest-1.6.8 docs/plain-requests.md
flexirest-1.6.7 docs/plain-requests.md
flexirest-1.6.6 docs/plain-requests.md