Solved

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

  • 10 August 2022
  • 8 replies
  • 657 views

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?

icon

Best answer by JasonM 18 August 2022, 06:24

View original

8 replies

Userlevel 5
Badge +1

@JasonM 

 

Can you please try with below options.

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

 

Userlevel 4
Badge

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

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.

Userlevel 5
Badge +1

@JasonM 

it should be . kindly try this option.

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

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)

 

Userlevel 4
Badge

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

 

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

Userlevel 4
Badge

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

Reply