Hello,
I’m trying to pass the following simple API call to my NGINX server:
curl --location 'https://latest.testing.ca/inventory/alerts
–header ‘Content-Type: application/json’
–form ‘quanity=“30303”’
–form ‘inventory_num=“686180275612312”’
–form ‘code=“SI”’
–form ‘alert=“none”’
In my NGINX code (see below), I’m trying to use proxy_set_body to capture my POST api body parameters (i.e. quantity, inventory_num, code, alert) and relay them to my backend bubble server. Everything works well with the call except for my api body parameters are not being captured by my nginx server, the values are always empty (i.e. no values for quantity, inventory_num, code, alert) . When I hard code the values in my nginx code, the hard coded values get relayed to my backend bubble server.
What am I doing wrong? Is there another NGINX directive that I should be using instead of proxy_set_body? Or, am I declaring my quantity, inventory_num, code, alert as variables incorrectly (i.e. “$arg_quantity”, “$arg_inventory_num”, “$arg_code”, “$arg_alert”}?
I appreciate any advice!
server {
listen 443 ssl;
server_name latest.testing.ca;
resolver 8.8.8.8;
location /inventory/alerts {
proxy_pass https://final.testing.ca/version-test/api/1.1/wf/inventory-alerts;
proxy_method POST; # Use POST method for alerts
proxy_ssl_server_name on; # Ensure SNI is passed during the SSL handshake
proxy_set_body '{"quantity":"$arg_quantity", "inventory_num":"$arg_inventory_num", "code":"$arg_code", "alert":"$arg_alert"}';
add_header X-Proxy-Passed "true";
}
}