How to get data from webhook with content-type: application/x-www-form-urlencoded;charset=UTF-8?

Dian Reid

I have setup a webhook in zoho crm but when ever i try to fetch the data with json_decode(file_get_contents("php://input"), true) it is always blank. From the look of the content-type the data is not json, i ahve tried everything and i still can't get the data from the webhook.

Any help is much appreciated.

Capture of HTTP POST Request: enter image description here

add_action( 'rest_api_init', 'register_api_hooks' );

function register_api_hooks() {
    register_rest_route( 'ep-to-zoho-crm/v1', '/updatecompany', array(
        'methods'  => 'POST',
        'callback' => 'webhook_listener',
    ));
};

function webhook_listener($request){
    // We don't want to process if it did not come from webhook
    //if( !isset( $_GET['companyid'] ) ) { return; }

    //$data = $request->get_param( 'companyid' );

    if ( isset( $_REQUEST['companyid'] ) ) {
        file_put_contents(plugin_dir_path( __FILE__ ).'crm.txt', 'works');
    }else{
        file_put_contents(plugin_dir_path( __FILE__ ).'invalid.txt', 'invalid');
    } 

    /*$data = $_POST['companyid'];

    file_put_contents(plugin_dir_path( __FILE__ ).'crm.txt', $data);


    $json_string = json_encode($_POST);

    $save = file_put_contents(plugin_dir_path( __FILE__ ).'crm.json', $json_string);*/
}
add_action( 'init', 'webhook_listener' );

and then my webhook url looks like this https://example.com/wp-json/ep-to-zoho-crm/v1/updatecompany

Dian Reid

This issue was my server was not configured correctly and so the data was being blocked when sent to my webhook url.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Use RestTemplate with object as data and application/x-www-form-urlencoded content type?

Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

Spring Boot - Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

How to fix validation error getting from openapi go code generator for an API which consumes application/x-www-form-urlencoded content type?

How to perform a GET request with application/x-www-form-urlencoded content-type in Go?

Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported for @RequestBody MultiValueMap

Android Retrofit: content type as application/x-www-form-urlencoded

How to get response of content type application/x-www-form-urlencoded by passing parameters in laravel

How to remove charset=utf-8 in a Content-Type header, generated by spring-boot

how to post data in node.js with content type ='application/x-www-form-urlencoded'

How do I post data using okhttp library with content type x-www-form-urlencoded?

file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded with imgur API

Swift - How to send POST request with "x-www-form-urlencoded" content-type

How do I get raw request body using servicestack with content-type set to application/x-www-form-urlencoded?

How do I set up a function app to extract data from media type 'application/x-www-form-urlencoded'

Content-Type header [application/x-www-form-urlencoded] is not support error when import json data into elastic

How to send a POST request with Content-Type "application/x-www-form-urlencoded"

How to set Request and response "Content-Type" to "application/json;charset=UTF-8"?

How to post request with spring boot web-client for Form data for content type application/x-www-form-urlencoded

How to send post request with content-type x-www-form-urlencoded android retrofit

Spring reactive WebClient GET json response with Content-Type "text/plain;charset=UTF-8"

How to remove charset=utf8 from Content-Type header generated by HttpClient.PostAsJsonAsync()?

Akka HTTP how to POST singleRequest with Content-Type application/x-www-form-urlencoded

How to escape + in post call content type as application/x-www-form-urlencoded

How test Post request with custom object in content type application/x-www-form-urlencoded?

How to solve error at xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")?

How to remove charset=UTF-8 from Content-Type response header in Spring boot(v2.4.2)

file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded

How to add "application/x-www-form-urlencoded" as Content-type in .Net httpClient

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    pump.io port in URL

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  14. 14

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  15. 15

    How to use merge windows unallocated space into Ubuntu using GParted?

  16. 16

    flutter: dropdown item programmatically unselect problem

  17. 17

    Pandas - check if dataframe has negative value in any column

  18. 18

    Nuget add packages gives access denied errors

  19. 19

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  20. 20

    Generate random UUIDv4 with Elm

  21. 21

    Client secret not provided in request error with Keycloak

HotTag

Archive