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

Issue with post payload not passing through #66

Closed
free-soellingeraj opened this issue Oct 19, 2022 · 5 comments
Closed

Issue with post payload not passing through #66

free-soellingeraj opened this issue Oct 19, 2022 · 5 comments

Comments

@free-soellingeraj
Copy link

My script is:

#!/bin/bash

echo "Starting background job"
echo "Hook information: name=$hook_name, id=$hook_id, method=$hook_method"
echo "Query parameter: foo=$foo"
echo "Header parameter: user-agent=$user_agent"
echo "Script parameters: ${1}"


nohup ./scripts/long.sh >/tmp/long.log 2>&1  &

echo "Background job started."

I run the test as is outlined in the README.md

curl -d @test.json http://***.compute-1.amazonaws.com:8080/shoebox-test -u aaron:***** 

where test.json is

% cat test.json 
{"message": "this is a test"}

and my response shows the payload does not get passed through.

% curl -d @test.json http:/***.compute-1.amazonaws.com:8080/shoebox-test -u aaron:****** 
Starting background job
Hook information: name=shoebox-test, id=12, method=POST
Query parameter: foo=
Header parameter: user-agent=curl/7.79.1
Script parameters: 
Background job started.

Can you suggest how I can debug?

@free-soellingeraj
Copy link
Author

Here's the verbose output from curl:

% curl -d @test.json http://***.amazonaws.com:8080/shoebox-test -u aaron:****** -v
*   Trying ***:8080...
* Connected to ******.compute-1.amazonaws.com (***) port 8080 (#0)
* Server auth using Basic with user 'aaron'
> POST /shoebox-test HTTP/1.1
> Host: ec2-44-202-194-148.compute-1.amazonaws.com:8080
> Authorization: ******
> User-Agent: curl/7.79.1
> Accept: */*
> Content-Length: 29
> Content-Type: application/x-www-form-urlencoded
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Access-Control-Allow-Headers: Accept, Content-Type, Content-Length, Accept-Encoding, Authorization
< Access-Control-Allow-Methods: *
< Access-Control-Allow-Origin: *
< Cache-Control: no-cache
< Connection: keep-alive
< X-Content-Type-Options: nosniff
< X-Hook-Id: 13
< X-Request-Id: 1666192709856983487
< Date: Wed, 19 Oct 2022 15:18:29 GMT
< Content-Type: text/plain; charset=utf-8
< Transfer-Encoding: chunked
< 
Starting background job
Hook information: name=shoebox-test, id=13, method=POST
Query parameter: foo=
Header parameter: user-agent=curl/7.79.1
Script parameters: 
Background job started.
* Connection #0 to host ***.compute-1.amazonaws.com left intact

@free-soellingeraj
Copy link
Author

By switching to debug level = DEBUG, I confirmed that the payload is getting to the server:

INF 2022/10/19 15:49:50.920017 hook shoebox-test#1 started...
DBG 2022/10/19 15:49:50.920021 hook shoebox-test#1 script: scripts/shoebox-test.sh
DBG 2022/10/19 15:49:50.920074 hook shoebox-test#1 parameter: [{"message":_"this_is_a_test"}= authorization=Basic YWFyb246MTIzNA== user_agent=curl/7.79.1 accept=*/* content_length=29 content_type=application/x-www-form-urlencoded]
DBG 2022/10/19 15:49:50.920268 hook shoebox-test#1 output file: /tmp/shoebox_test_1_20221019_1549.txt
INF 2022/10/19 15:49:50.922574 hook shoebox-test#1 done [SUCCESS]
INF 2022/10/19 15:49:50.922684 65.49.31.245 - - [19/Oct/2022:15:49:50 +0000] "POST /shoebox-test HTTP/1.1" 200 186 "" "curl/7.79.1" "REQID=1666194590919863614"

@ncarlier
Copy link
Owner

Hi, this is because your content-type.

Request body (depending the Media Type):
application/x-www-form-urlencoded: keys and values are converted to script variables
text/* or application/json: payload is transmit to the script as first parameter.

If you specify the content type with curl this should work as expected: curl -X POST -H 'Content-Type: application/json' ...

@ncarlier
Copy link
Owner

BTW, you are right, the README is not correct and should specify the content type as well. Thanks for pointing this out.

@free-soellingeraj
Copy link
Author

no problem, thanks!
That worked.

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

No branches or pull requests

2 participants