Sha256: c3011cbf9f609798ae1c6135141a04dbd225175521736986a714d07e8d228df2

Contents?: true

Size: 1.16 KB

Versions: 20

Compression:

Stored size: 1.16 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 string containing the response

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

20 entries across 20 versions & 1 rubygems

Version Path
flexirest-1.12.4 docs/plain-requests.md
flexirest-1.12.3 docs/plain-requests.md
flexirest-1.12.2 docs/plain-requests.md
flexirest-1.12.1 docs/plain-requests.md
flexirest-1.12.0 docs/plain-requests.md
flexirest-1.11.3 docs/plain-requests.md
flexirest-1.11.2 docs/plain-requests.md
flexirest-1.11.1 docs/plain-requests.md
flexirest-1.11.0 docs/plain-requests.md
flexirest-1.10.12 docs/plain-requests.md
flexirest-1.10.11 docs/plain-requests.md
flexirest-1.10.10 docs/plain-requests.md
flexirest-1.10.9 docs/plain-requests.md
flexirest-1.10.8 docs/plain-requests.md
flexirest-1.10.7 docs/plain-requests.md
flexirest-1.10.6 docs/plain-requests.md
flexirest-1.10.5 docs/plain-requests.md
flexirest-1.10.4 docs/plain-requests.md
flexirest-1.10.3 docs/plain-requests.md
flexirest-1.10.2 docs/plain-requests.md