DJohnson
DJohnson

Reputation: 919

REST Callback with Paw

I'm looking for help utilizing information from the header response in a REST API call.

I submit a request that returns the first 100 of 3600 records. The header response includes a Link value that has the next URL to get the next set of records (rel="next") and a link to the last page of records (rel="last") etc.

Response Header:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
x-server-name: {removed}
Link: <https://{server.domainname.com}/v4_6_release/apis/3.0/company/companies?pageSize=100&page=2>; rel="next", <https://{server.domainname.com}/v4_6_release/apis/3.0/company/companies?pageSize=100&page=35>; rel="last"
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 31 Mar 2016 20:56:18 GMT
Connection: close
Content-Length: 102673

I can access the entire "Link" header value, but how can I get the specific values (URL's) from this item in Paw so I can use them or do I just need to do that in my code (Swift/Alamofire)?

Upvotes: 2

Views: 270

Answers (1)

Micha Mazaheri
Micha Mazaheri

Reputation: 3481

Paw doesn't provide an explicit parsing of the Link header yet (would be nice to add though!), but you can easily work around this using the RegExp dynamic value. In fact, you can wrap your retrieval of the Link header inside a RegExp search/replace pattern and extract the link you care about. Here's an example:

Extract field from a header with Paw's RegExp and Header dynamic values

I use here the regexp .*\<([^\>]+)\>; rel="last".* that will match the full string, and the replacement $1 to only get the Link part we care about. I hope this helps!

Upvotes: 1

Related Questions