Skip to main content
Solved

HTTP Client Error - Issue when calling API with a 'greater than' or 'less than' sign in parameters

  • August 10, 2022
  • 8 replies
  • 1215 views

JasonM
Fan

I am trying to call the GitHub endpoint https://api.github.com/repos/my-org/my-repo/actions/runs?created=>2022-08-01

I have tried all other available parameters (https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs-for-a-repository) and the only parameter that doesn’t work is the date filter “created”.

 

It returns an error, which I narrowed down to the ‘greater than’ or ‘less than’ signs:

 

The query runs as-is in postman and in control hub I have tested using HTML encoding for the entire parameter string, HTML encoding just the < and > signs as well as moving the API parameters to the pipeline global parameters section. All with no luck. Does anyone know if it’s the API itself, the Resource URL field that can’t handle these characters, or something else?

Best answer by JasonM

Thanks @saleempothiwala, combining a few of your responses has allowed me to find the issue, the call is expecting a second equals sign and only works with the %3E encoding for the ‘greater than’ sign, this is the working call:

/runs?created==%3E2022-08-01

View original
Did this topic help you find an answer to your question?

8 replies

Bikram
Headliner
Forum|alt.badge.img+1
  • Headliner
  • 486 replies
  • August 11, 2022

@JasonM 

 

Can you please try with below options.

https://api.github.com/repos/my-org/my-repo/actions/runs?Created[gt]2022-08-01

 


saleempothiwala
Headliner
Forum|alt.badge.img

@JasonM try as @Bikram suggested and also try to replace ‘>’ with ‘&gt’ or %3E of all fails :-)


JasonM
Fan
  • Author
  • Fan
  • 3 replies
  • August 12, 2022

Thanks for your suggestions, unfortunately none of them are working. Here are the results, there are total number of 150 records dating back 12 months but if the date filter was working, then the result should only be 14 records (confirmed via Postman).

 

HTTP Client Tests:

/runs → 150 records

/runs?created=>2022-08-01 → illegal character in query (returns 14 in Postman)

/runs?created=[gt]2022-08-01 → 0 records

/runs?created:[gt]2022-08-01 → 150 records

/runs?created=&gt2022-08-01 → 150 records

/runs?created=&gt;2022-08-01 → 150 records

/runs?created=%3E2022-08-01 → 150 records

 

It looks like the response defaults to the entire dataset if the parameter is invalid. I can’t explain the zero record response though. I have a feeling that the URL isn’t being wrapped or encoded as expected by StreamSets.


Bikram
Headliner
Forum|alt.badge.img+1
  • Headliner
  • 486 replies
  • August 12, 2022

@JasonM 

it should be . kindly try this option.

/runs?created[gt] = 2022-08-01 


JasonM
Fan
  • Author
  • Fan
  • 3 replies
  • August 15, 2022

results:

/runs?created[gt] = 2022-08-01 → doesn’t like spaces (javax.ws.rs.core.UriBuilderException: java.net.URISyntaxException: Illegal character in query)

/runs?created[gt]=2022-08-01 → 0 records returned (no spaces)

/runs?created[gt]+=+2022-08-01 → 0 records returned (‘+’ to replace illegal spaces)

 


saleempothiwala
Headliner
Forum|alt.badge.img

@JasonM  have you checked on Postman if any URL encoding header is being passed. Try to add the same headers in StreamSets too

 


JasonM
Fan
  • Author
  • Fan
  • 3 replies
  • Answer
  • August 18, 2022

Thanks @saleempothiwala, combining a few of your responses has allowed me to find the issue, the call is expecting a second equals sign and only works with the %3E encoding for the ‘greater than’ sign, this is the working call:

/runs?created==%3E2022-08-01


saleempothiwala
Headliner
Forum|alt.badge.img

@JasonM thanks for the update. glad to know that you managed to get it working :-)


Reply