Answers.Body: <p>This is typically handled by adding a webhook endpoint to your extension.  The Mailchimp extension does this - see <a href="https://github.com/veda-consulting/uk.co.vedaconsulting.mailchimp/blob/master/CRM/Mailchimp/Page/WebHook.php" rel="nofollow noreferrer">Webhook.php</a>.</p>
  
  <p>If you've already written your API action, it shouldn't be too tough to use a webhook to grab the data and push to API.</p>
  
  <p>It sounds like maybe you're past this point, but <a href="https://lab.civicrm.org/dev/financial/issues/55" rel="nofollow noreferrer">https://lab.civicrm.org/dev/financial/issues/55</a> is an issue I raised to deal with handling POST data stored as JSON.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-06T00:16:44.690Z
Answers.LastActivityDate: 2020-03-06T00:16:44.690Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p><strong>UPDATE</strong>: This answer won't work. See comments.</p>
  
  <hr>
  
  <p>You can always access $_POST.</p>
  
  <p>There is CRM_Utils_Request::retrieve() - it serves a different purpose but you could also use it, specifying method 'POST'. It's not technically a supported API call though. See <a href="https://github.com/civicrm/civicrm-core/blob/5.22.1/CRM/Utils/Request.php#L51" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/5.22.1/CRM/Utils/Request.php#L51</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-04T19:07:05.343Z
Answers.Text: Yeah, I expected $_POST to work but somehow it gives me a blank array.
Answers.UserDisplayName: Rupert Raphael Amodia
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-04T19:27:03.863Z
Answers.Text: So, $_POST didn't work because it doesn't work for JSON content type. I had to use `file_get_contents('php://input')` like [this](https://stackoverflow.com/questions/18866571/receive-json-post-with-php#answer-18867369)
Answers.UserDisplayName: Rupert Raphael Amodia
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-04T20:43:23.943Z
Answers.Text: Oh I see. It's not specifically that it's JSON, it's that it isn't parsed by php into $_POST because it's not a `param=value&param2=value2` type of http request where content-type would be application/x-www-form-urlencoded.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-05T02:47:01.250Z
Answers.Text: Oh, I see. Thank you for that nugget of info
Answers.UserDisplayName: Rupert Raphael Amodia
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-04T17:09:07.843Z
Answers.LastActivityDate: 2020-03-04T20:44:04.500Z
Answers.LastEditDate: 2020-03-04T20:44:04.500Z
Answers.UserDisplayName: Demerit
Body: <p>I'm developing a custom API v3 action which is intended to handle a webhook request from Zoom (<a href="https://marketplace.zoom.us/docs/api-reference/webhook-reference" rel="nofollow noreferrer">https://marketplace.zoom.us/docs/api-reference/webhook-reference</a>). Zoom follows REST standards by putting the data inside the request's body (not like the CiviCRM api where you put the data inside a json parameter). So, is there a way to access the request's body from my custom action or custom extension?</p>
  
Tags: <api><extension><developer>
Title: Custom API Action: Access Request Body
ThreadText: # Custom API Action: Access Request Body
  
  (Asked by: username_0 on 2020-03-04)
  
  I'm developing a custom API v3 action which is intended to handle a webhook request from Zoom (<https://marketplace.zoom.us/docs/api-reference/webhook-reference>). Zoom follows REST standards by putting the data inside the request's body (not like the CiviCRM api where you put the data inside a json parameter). So, is there a way to access the request's body from my custom action or custom extension?
  
  **Tags:** api, extension, developer
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-03-06. Score: 2
  
  This is typically handled by adding a webhook endpoint to your extension. The Mailchimp extension does this - see [Webhook.php](https://github.com/veda-consulting/uk.co.vedaconsulting.mailchimp/blob/master/CRM/Mailchimp/Page/WebHook.php).
  
  If you've already written your API action, it shouldn't be too tough to use a webhook to grab the data and push to API.
  
  It sounds like maybe you're past this point, but <https://lab.civicrm.org/dev/financial/issues/55> is an issue I raised to deal with handling POST data stored as JSON.
  
  
  ---
  
  ### Answer by username_2 on 2020-03-04. Score: 1
  
  **UPDATE**: This answer won't work. See comments.
  
  ---
  
  You can always access $\_POST.
  
  There is CRM\_Utils\_Request::retrieve() - it serves a different purpose but you could also use it, specifying method 'POST'. It's not technically a supported API call though. See <https://github.com/civicrm/civicrm-core/blob/5.22.1/CRM/Utils/Request.php#L51>
  
  > **Comments:**
  > **username_0**: Yeah, I expected $_POST to work but somehow it gives me a blank array.  
  > **username_0**: So, $_POST didn't work because it doesn't work for JSON content type. I had to use `file_get_contents('php://input')` like [this](https://stackoverflow.com/questions/18866571/receive-json-post-with-php#answer-18867369)  
  > **username_2**: Oh I see. It's not specifically that it's JSON, it's that it isn't parsed by php into $_POST because it's not a `param=value&param2=value2` type of http request where content-type would be application/x-www-form-urlencoded.  
  > **username_0**: Oh, I see. Thank you for that nugget of info  
  
  ---
  
  