GOAL endpoint returning 404 Not Found

I am getting 404 Not found error for Goals endpoint
Curl request I am using:
curl -H 'Authorization: Bearer ****' -H 'Accept: application/json' -A 'Jersey/2.31' 'https://fivetran-sandbox.pipedrive.com/goals/find?period.start=2021-08-24&period.end=2021-08-25'

Domain fivetran-sandbox.pipedrive.com is correct and it’s working for other endpoints

Hi @pm-fivetran

Could you try https://fivetran-sandbox.pipedrive.com/api/v1/goals/find?

*API example

Thanks, @mykhailo this worked. But why did url specified in docs did not worked?

@pm-fivetran API docs endpoints are described for https://api.pipedrive.com hence https://api.pipedrive.com/v1/goals/find works as expected. But the recommended way is to use company domain, https://fivetran-sandbox.pipedrive.com/api/v1/goals/find, in that case you need to use /api/v1 not just /v1.

Thanks @mykhailo this worked for GOAL endpoint, however I am getting OK text message but 404 Not Found error for GOAL_RESULT endpoint
Error message:-

    "success": true,
    "statusCode": 20000,
    "statusText": "OK",
    "service": "statistics-goals-api",
    "data": {
        "code": 404,
        "httpCode": 404,
        "message": "Not Found",
        "severity": 1

Curl Request:-

curl -H 'Authorization: Bearer ******' -H 'Accept: application/json' -A 'Jersey/2.31' 'https://infrakit.pipedrive.com/api/v1/goals/6dde16a3442a2997bb505adc1f09513b/results?period.start=2010-06-21&period.end=2021-08-27'

Any idea why I am getting this error?

Hi @pm-fivetran

This error can happen if your period.start does not match Goal’s period start, as one cannot ask for results of a goal if the goal is not running during the specified period.

Thanks @mykhailo got it, So we can query GOAL_RESULT using duration.start and duration.end of a goal. So it means duration.start would always be not null.

Still for some goal_ids I am getting 500 internal server error, my period.start = goal.start and period.end = goal.end
Error message:

    "success": false,
    "statusCode": 10001,
    "statusText": "An unknown error occurred",
    "service": "statistics-goals-api"

Curl request:-

curl -H ‘Authorization: Bearer ****’ -H ‘Accept: application/json’ -A ‘Jersey/2.31’ ‘https://infrakit.pipedrive.com/api/v1/goals/0cf7d198b051d30aaad599e86500b376/results?period.start=2019-01-01&period.end=2019-12-31

Could you check if you can see stages of a pipeline where goal is connected to?

For example, here is my goal

And if I make GET /stages?pipeline_id=17, I get response

@mykhailo When I tried to make request /stages?pipeline_id=5 and response is 200 OK
But data is null

    "success": true,
    "data": null

Could you also try GET /pipelines/{id} (Pipedrive API v1 Reference)

If the response is 404 then the connected pipeline does not exist anymore and it breaks the API call.

*Messaging and logic can be improved for this case (notified a team already).

Actually /pipelines/5 is working and I am also able to get the data, its not giving 404

I double-checked one more time and it seems like it might fail for both cases, when a connected pipeline does not exist, or a connected pipeline exists but has no stages.

As your pipeline exists but has no stages, can you add a stage there and try again?

Thanks,@mykhailo. I am getting 403 FORBIDDEN error for the following tables:-

Does this table need some extra permissions?
Except for these

Hi @pm-fivetran, if not a regular user installs the app that uses admin’s APIs, in some cases a user can get 403.

I recently made an example for webhooks, Creating new webhooks through API - #8 by mykhailo which also might cover your case.

Also, 403 can happen when you try to call an endpoint with access token that has no access to that endpoint. For example, I see that you have something related to Leads, but you don’t have leads scope. Which means, when you call Leads endpoints you will get 403.

More about endpoints and permissions here

Hi @mykhailo I want to update the scopes you mentioned in my app.
Currently, my other endpoints are working fine, so when I update scopes in my app then would other endpoints also fail on 401 UnAuthorized error, or would they be working fine?

Hi @pm-fivetran

Here is what happens when an app gets new scopes.

so when I update scopes in my app then would other endpoints also fail on 401 UnAuthorized error, or would they be working fine?

They will be working fine, once you get a new access token with refresh_token, as the existing access token will be invalidated.

And in order to call new endpoints (in your case Leads endpoints), an app user has to re-authorize.

Thanks @mykhailo So just to confirm once I update the scopes other endpoints would succeed once we refresh token, customers wont need to re-authorise with app if they dont need these new endpoints

Yes, but as I mentioned before, existing access tokens will become invalid, similar to the case when they expire and need to be refreshed. Hence, your app should be able to handle this case, otherwise once a scope is added existing users will not be able to use the app without re-install.

If it’s still unclear, I do recommend creating another app, just for testing (no need to publish), and test that scenario there (no need in code, you can make requests with Postman for example). So you could see what happens with tokens before a scope is added and after.