If the same request worked at one point but is no longer working, the problem is most likely due to a change to the api or the object you are trying to retrieve.
You can use this curl request to make sure you are using an available API version, just make sure to change MyDomainName
you the subdomain for your organization.
curl https://MyDomainName.my.salesforce.com/services/data/ -H "Authorization: Bearer token".```
If the API version is available, check on the sobject you are looking for with the following curl request. Again, MyDomainName
should match the subdomain of your organization, the version should match the version you are trying to use, and you will need to authenticate this time.
curl https://MyDomainName.my.salesforce.com/services/data/v56.0/sobjects/ -H "Authorization: Bearer token"
If the object you are trying to write to is not in the returned list of sobjects, check the settings in the Salesforce UI to make sure it exists and that your api token has access to it.
Source:
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_versions.htm
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_describeGlobal.htm