Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix: #5533 - Enabled reading request body for HTTP POST requests. #13853

Merged
merged 6 commits into from
Feb 2, 2024

Conversation

emrahtokalak
Copy link
Contributor

It is provided to read the data in the body of the requests sent in post type.

Example Post request:

curl --location 'http://localhost:5001/api/queries/YourQueryName' \ --header 'Content-Type: application/json' \ --data '{ "EmployeeIds": "4s726tsb5jpdhrny3v0759jjw0,4znzn2eecdazvrc2kh2vhm4yn9,4ggs0tgqrat127jgsrps1rr75g,4dts0wxjsp5p1saeprkk67redt,4dts0wxjsp5p1saeprkk67redt,48bweg5d4chwn08yzc1brwys5v" }'

Javascript example:

$.ajax({
  url: '{{ Site.BaseUrl }}/api/queries/GetListHrmItemEmployeeKpi',
  type: 'POST',
  data: JSON.stringify({ EmployeeIds: '4s726tsb5jpdhrny3v0759jjw0,4znzn2eecdazvrc2kh2vhm4yn9,4ggs0tgqrat127jgsrps1rr75g,4dts0wxjsp5p1saeprkk67red' }),
  contentType: 'application/json',
  async: false,
  success: function (response) {
    console.log(response);
  },
  error: function (xhr, textStatus, error) {
    console.error(error);
  }
});`

@emrahtokalak
Copy link
Contributor Author

@dotnet-policy-service agree company="Medyasoft"

@emrahtokalak
Copy link
Contributor Author

Hi @sebastienros can you review this PR.

{
parameters = Request.Query["parameters"].ToString();
}
else if (Request.Method == "POST")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a breaking change. Before even in a POST the parameters query string would have been read, now it's not.

Instead could you check if the qyery string is set, and if not use the body when in a POST.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I fixed it. If the parameters are empty as query string in Post type, I get the request body value.

This way I can pass the long parameters I need.

Example:
{ "EmployeeIds": "4s726tsb5jpdhrny3v0759jjw0,4znzn2eecdazvrc2kh2vhm4yn9,4ggs0tgqrat127jgsrps1rr75g,4dts0wxjsp5p1saeprkk67redt,4dts0wxjsp5p1saeprkk67redt,48bweg5d4chwn08yzc1brwys5v" }

Copy link
Contributor

github-actions bot commented Feb 2, 2024

This pull request has merge conflicts. Please resolve those before requesting a review.

@sebastienros sebastienros enabled auto-merge (squash) February 2, 2024 22:47
@sebastienros sebastienros merged commit 042caa6 into OrchardCMS:main Feb 2, 2024
4 checks passed
urbanit pushed a commit to urbanit/OrchardCore that referenced this pull request Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants