Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support JSONB to query parameter conversion for GET in http #182

Open
kolpav opened this issue Dec 18, 2024 · 0 comments
Open

Support JSONB to query parameter conversion for GET in http #182

kolpav opened this issue Dec 18, 2024 · 0 comments

Comments

@kolpav
Copy link

kolpav commented Dec 18, 2024

Unlike http_get, the http function does not automatically convert JSONB payloads into query parameters for GET requests.
Would it be a good idea to add similar behaviour to http for consistency? Or maybe make http_get also accept http headers? Thats the main reason I am using http instead of http_get. Great project btw 👍


In http_get, JSONB data is automatically URL-encoded and appended to the URI

SELECT * FROM http_get('https://api.example.com/resource', jsonb_build_object('param1', 'value1'));

With http, this has to be done manually

SELECT * FROM http((
  'GET',
  'https://api.example.com/resource?' || urlencode(jsonb_build_object('param1', 'value1')),
  ARRAY[http_header('Authorization', 'Bearer token')],
  NULL,
  NULL
)::http_request);

By reading README.md I was expecting this would work

SELECT * FROM http((
    'GET',
    'https://api.example.com/resource',
    ARRAY[http_header('Authorization', 'Bearer token')],
    'application/x-www-form-urlencoded',
    jsonb_build_object(
      'param1', 'value1'
    )
  )::http_request);
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant