Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
290 views
in Technique[技术] by (71.8m points)

api - Counter for Pagination

I try to set up an API-Call and I need a specific header. I need a signature that will renew on every call including a offset. Thats what i have:

<#assign method = "GET">    
<#assign uri = "the_requestet_url?limit=30">    
<#assign body = "">    
<#assign timestamp = (.now?long / 1000)?split(".")[0]>    
<#assign gesamt>${method}${"
"}${uri}${"
"}${body}${"
"}${timestamp}</#assign>    
<#assign secret ="here_is_a_secret_key">    
<#assign signature = hmacSHA256(gesamt, secret, "hex")!>

The call is:

Accept=application/json    
HM-Timestamp=${timestamp}    
HM-Signature=${signature}    
HM-Client=here_is_a_client_id

The Api delivers max 30 entrys back and after i need an offset in

<#assign uri = "the_requestet_url?limit=30">

that counts up with every call and starts with the next 30 entrys.

The key has to be renewed every call. I think i need a counter in here but i didn′t get it to work

I will do the pagination that looks something like this:

<#assign row = target.addRow()>    
  
<#assign numRows = 0 />    
  
<#list json as p>    
 <#assign row = target.addRow()>    
    ${addColumns(row, p['product'])}    
    <#assign numRows = numRows + 1 />    
</#list>    
  
  
<#if (numRows > 0 && callcounter < callLimit)>    
    <#assign nextPageNumber = (callcounter + 1)>    
    ${nextUrl(initialUrl+"&page="+nextPageNumber)}    
</#if>    

Any idea how i can get the counter to work?

Thanks in advance and BR Enrico

question from:https://stackoverflow.com/questions/65849487/counter-for-pagination

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...