cannot assign all the values from HTTP Link response header in a variable

I get HTTP Link header from the backedn, like below. However, when I assign this in a variable in the javascript then only a part of the header is copied.

Link =<https://api.github.com/user/9287/repos?page=3&per_page=100>; rel=first,<https://api.github.com/user/9287/repos?page=1&per_page=100>; rel=next,<https://api.github.com/user/9287/repos?page=5&per_page=100>; rel=last

For example:

var link_headers = context.getVariable('response.header.Link');

when assigned to a variable, only copies first part(as below)

link_headers = <https://api.github.com/user/9287/repos?page=3&per_page=100>; rel=first

but, rest of the part of the header is not copied.

Is it something to do with the parsing or the length of the header?

There is a an npm package that helps in parsing the link header. (https://www.npmjs.com/package/parse-link-header)

Has anyone come across such problem?

Solved Solved
1 3 112
1 ACCEPTED SOLUTION

message.header.header_name.values

var link_headers = context.getVariable('response.header.Link.values');

https://docs.apigee.com/api-platform/reference/variables-reference

View solution in original post

3 REPLIES 3

message.header.header_name.values

var link_headers = context.getVariable('response.header.Link.values');

https://docs.apigee.com/api-platform/reference/variables-reference

Denis K that was lightning fast!!

It works 🙂

Thanks a lot.

Anytime, enjoy