Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6918925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:55:20+00:00 2026-05-27T09:55:20+00:00

Github supports post-receive hooks for notification of code changes, documented here . Now, to

  • 0

Github supports post-receive hooks for notification of code changes, documented here. Now, to test a hook server I need to post a bit of json and I’d like to use curl to do so. I’ve done this before but so infrequently that I tend to forget my solution.

As I recall, doing this has been tedious each time.

The Github folks provide this JSON document as an example of the data that will be POSTed on the parameter payload:

{
  "before": "5aef35982fb2d34e9d9d4502f6ede1072793222d",
  "repository": {
    "url": "http://github.com/defunkt/github",
    "name": "github",
    "description": "You're lookin' at it.",
    "watchers": 5,
    "forks": 2,
    "private": 1,
    "owner": {
      "email": "chris@ozmm.org",
      "name": "defunkt"
    }
  },
  "commits": [
    {
      "id": "41a212ee83ca127e3c8cf465891ab7216a705f59",
      "url": "http://github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59",
      "author": {
        "email": "chris@ozmm.org",
        "name": "Chris Wanstrath"
      },
      "message": "okay i give in",
      "timestamp": "2008-02-15T14:57:17-08:00",
      "added": ["filepath.rb"]
    },
    {
      "id": "de8251ff97ee194a289832576287d6f8ad74e3d0",
      "url": "http://github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0",
      "author": {
        "email": "chris@ozmm.org",
        "name": "Chris Wanstrath"
      },
      "message": "update pricing a tad",
      "timestamp": "2008-02-15T14:36:34-08:00"
    }
  ],
  "after": "de8251ff97ee194a289832576287d6f8ad74e3d0",
  "ref": "refs/heads/master"
}

Saving that as /tmp/example.json I thought that

 $ curl -XPOST -F "payload=@/tmp/example.json" http://localhost:3000/

would have been the correct invocation of curl, but I was not correct. Using my example project hooks the above results in:

127.0.0.1 - - [17/Nov/2011 22:20:51] "POST  HTTP/1.1" 200 - 0.0295
{:filename=>"example.json", :type=>"application/octet-stream", :name=>"payload", :tempfile=>#<File:/tmp/RackMultipart20111117-11639-1ecu4i1>, :head=>"Content-Disposition: form-data; name=\"payload\"; filename=\"example.json\"\r\nContent-Type: application/octet-stream\r\n"}

which, given the definition of the action for that end-point:

class HomeAction < Cramp::Action
  def start
    puts params[:payload]

    render 'thanks'
    finish
  end
end

is not quite expected. So, how can I use the command-line version of curl to post a bit of JSON as data, on parameter payload?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:55:20+00:00Added an answer on May 27, 2026 at 9:55 am

    I managed to make this work with the following:

    1. Save the json data in a file.
    2. Remove new lines from json file. (Vim command= :%s/\n//g)
    3. curl --data-urlencode payload@json_data.txt [URL]

    Seemed to provide identical results when posting to Postbin via GitHub & Curl.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(EDIT: This question is now outdated for my particular issue, as Google Code supports
Now that http://github.com/why/hpricot/wikis/home no longer exists.
I work mostly with Git and have a lot of code on github. I
I'm trying to install Community Engine using the instructions here: http://github.com/bborn/communityengine At first I
I'm using the HTTPClient gem ( http://github.com/nahi/httpclient ) for ruby, to post data to
I can compile this JNA example code (from step 2 of https://github.com/twall/jna/#getting_started ): package
I am using the encryptor gem from https://github.com/shuber/encryptor and need to be able to
Predis claim to have Client-side sharding (support for consistent hashing of keys). http://github.com/nrk/predis I
Github has the following recommendation for global git configuration ~/.gitconfig : [alias] # Is
github url I am using a simple search that displays search results: @adds =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.