Use correct /api/v2 path #260
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Tickets & Documents
My issue: #252
Forum entry that helped me solve it: https://devcommunity.pipedrive.com/t/persons-api-v2-returning-html-content/19618
Description
The configuratio uses the url
.../v2instead of.../api/v2and thus returnsContent-Type: text/htmlinstead ofContent-Type: application/json, which can not be correctly handled by the client.Type of PR
🐛 Bug Fix
Manual testing
To reproduce:
pddebug.txtisuse Pipedrive\versions\v2\Configuration as ConfigurationV2;
use Pipedrive\versions\v2\Api\DealsApi as DealsApiV2;
...
// create Configuration for API v2
$config = (new ConfigurationV2());
$configv2->setDebug(true);
$configv2->setDebugFile(storage_path("pddebug.txt"));
// set parameters and tokens
$config->setClientId(env('PIPEDRIVE_CLIENT_ID'));
$config->setClientSecret(env('PIPEDRIVE_CLIENT_SECRET'));
$config->setAccessToken($token->access_token);
$config->setRefreshToken($token->refresh_token);
$config->refreshToken();
$config->setHost("https://my-company.pipedrive.com/api/v2"); // Explicitly set the correct url
$dealsApi = new DealsApiV2(null, $config);
$discountResponse = $dealsApi->getDeal(123); // now it works