vector icon indicating copy to clipboard operation
vector copied to clipboard

enhancement(http_client source): add support for request body

Open benjamin-awd opened this issue 1 month ago • 1 comments

Summary

This PR allows a request body to be sent via the http_client source with additional support for VRL.

Vector configuration

As a raw string:

sources:
  api:
    type: http_client
    endpoint: https://foobar.com/api/audit/search
    method: POST
    headers:
      Accept:
        - application/json
    auth:
      strategy: bearer
      token: ${API_TOKEN}
    body: |
      {
          "searchStatements": [{
              "column": "auditAction",
              "operator": "=",
              "value": "DELETE"
          }]"
      }

with VRL:

sources:
  api:
    type: http_client
    endpoint: https://foobar.com/api/audit/search
    method: POST
    headers:
      Accept:
        - application/json
    auth:
      strategy: bearer
      token: ${API_TOKEN}
    body:
      value: |
        encode_json({
          "searchStatements": [{"column": "auditAction", "operator": "=", "value": "DELETE"}],
          "timestamp": now()
        })
      type: vrl

How did you test this PR?

Change Type

  • [ ] Bug fix
  • [x] New feature
  • [ ] Non-functional (chore, refactoring, docs)
  • [ ] Performance

Is this a breaking change?

  • [ ] Yes
  • [x] No

Does this PR include user facing changes?

  • [x] Yes. Please add a changelog fragment based on our guidelines.
  • [ ] No. A maintainer will apply the no-changelog label to this PR.

References

  • Closes #14758

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please run make build-licenses to regenerate the license inventory and commit the changes (if any). More details here.

benjamin-awd avatar Nov 06 '25 13:11 benjamin-awd

Hi @pront,

Have added a note about the default content type in 64721f7d9.

I think the current unit tests should provide enough coverage, so will leave the integration test suite as-is. Failing docs check should be addressed by 83a4621f8 🙏

benjamin-awd avatar Nov 12 '25 10:11 benjamin-awd

hey @thomasqueirozb, any blockers on this one? would like to merge before any drift occurs 🙏

benjamin-awd avatar Dec 12 '25 15:12 benjamin-awd

Hi @benjamin-awd. We missed this one, sorry. Since pront gave the approval and had even queued it I'll make an exception and include it in the release tomorrow since it should've been merged quite some time ago.

thomasqueirozb avatar Dec 15 '25 18:12 thomasqueirozb