Getting 403 error when trying to subscribe via code

Im trying to subscribe, the login is responding 200 and returning an access token but when trying to subscribe it throws 403, here is the code.
Thanks in advanced.

private createAxiosInstance = async () => {
this.axiosInstance = axios.create({
baseURL: this.baseUrl,
});

    const config = {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
        },
    };

    const body = stringify({
        client_id: this.client_id,
        client_secret: this.client_secret,
        grant_type: 'client_credentials',
    });

    const {
        data: { access_token },
    }: AxiosResponse<{ access_token: string; id_token: string }> = await this.axiosInstance.post(
        '/auth/realms/main/protocol/openid-connect/token',
        body,
        config
    );
    this.axiosInstance.interceptors.request.use(config => {
        config.headers.Authorization = `Bearer ${access_token}`;
        return config;
    });
};

…some code

await this.createAxiosInstance();

        const payload_1 = {
            planetApiKey: process.env.PLANET_ACCESS_KEY,
            name,
            collection_id,
            input: {
                provider,
                bounds: {
                    geometry: aoi,
                    properties: {
                        crs: 'http://www.opengis.net/def/crs/EPSG/0/4326',
                    },
                },
                data: {
                    itemType: 'PSScene',
                    productBundle: 'analytic_udm2',
                    dataFilter: {
                        timeRange: {
                            from,
                            to,
                        },
                    },
                    harmonizeTo: 'NONE',
                },
            },
        };

        const response: AxiosResponse<SubscriptionResponse> = await this.axiosInstance.post(
            'api/v1/dataimport/subscriptions',
            payload_1
        );
        await axios.post(`api/v1/dataimport/subscriptions/${response.data.id}/confirm`);

ERROR:

{
status: 403,
reason: “Forbidden”,
message: “Invalid or expired account.”,
code: “COMMON_INSUFFICIENT_PERMISSIONS”,
}

Hi!

Based on the nature of your request, we are opening a Planet Support ticket on your behalf. We will follow up directly via email.

The issue was solved by our technical support team; we identified an issue with the building of the payload.

As described in the documentation, when creating orders or subscriptions the Planet API Key needs to be inside the inputs object.

https://docs.sentinel-hub.com/api/latest/reference/#tag/dataimport_subscription/operation/dataImport_createSubscription
https://docs.sentinel-hub.com/api/latest/reference/#tag/dataimport_order

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.