phprestrestful-authenticationfedex

FedEx Api: Bad Request Error, Missing or duplicate parameters. Please modify your request and try again


For some reason, I'm getting a 400 Bad Request error when I'm sending my authentication to FedEx for my API. Here is my code:

$payload = [
    'grant_type' => 'client_credentials',
    'client_id' => self::$apiKey,
    'client_secret' => self::$apiSecret,
];

$api = new App_ApiTransaction('POST', self::$authEndpoint, $payload, App_ApiTransaction::ENCODE_JSON);

$api->addHeader('Content-Type', 'application/x-www-form-urlencoded');

I tried using GET, but I was getting a 405 error. Also, this is a custom header function.

What could be causing the issue?


Solution

  • Found the solution, here is what I had to do:

     $payload = ('grant_type=client_credentials&client_id='.self::$apiKey.'&client_secret='.self::$apiSecret);
    

    Basically changed the Payload to the correct format