Freshdesk Data Storage查询失败:API返回404记录未找到
Hey there, let's break down why you're hitting that 404 when querying Freshdesk Data Storage even though your write code works. I've run into similar quirks before, so here are the most likely fixes to check:
Double-check your key's exact spelling and case
Freshdesk's Data Storage keys are case-sensitive. If you stored data with a key likeuserSettings_123, querying withusersettings_123orUserSettings_123will fail. Copy-paste the key directly from your storage code to your query code to eliminate typos.Verify you're using the same scope and context parameters
This is the most common culprit. Data Storage has different scopes (global, ticket, contact, etc.), and you need to match the exact scope and context ID used during storage. For example:- If you stored data with
scope: 'ticket'andticket_id: 456, your query must include both parameters—omittingticket_idor using a different one will return a 404. - Here's a quick example of matching storage and query code:
// Storage code (works) fdClient.data.set('ticket_note', {text: 'Follow up tomorrow'}, {scope: 'ticket', ticket_id: 456}) .then(res => console.log('Stored successfully')) .catch(err => console.error('Storage error', err)); // Matching query code (must include same scope/context) fdClient.data.get('ticket_note', {scope: 'ticket', ticket_id: 456}) .then(data => console.log('Fetched data:', data)) .catch(err => console.error('Fetch error', err));
- If you stored data with
Confirm the storage operation actually succeeded (don't just assume)
Even if your storage code doesn't throw an error, it's worth logging the success response to ensure the data was persisted. Sometimes silent issues (like partial permissions) can make it look like storage worked, but the record never got saved. Add a console log in your storage'sthen()block to check for a valid response object.Check your app's permissions and installation scope
Make sure your Freshdesk app has thedata_storagepermission enabled in the developer console. Also, if your app is only installed for specific groups or agents, you might be trying to query data outside that access scope. Double-check the app's installation settings in your Freshdesk account.Wait a beat for sync (rare but possible)
Occasionally, Freshdesk's storage service has a tiny delay between writing and being able to read the record. If you're querying immediately after storage, try adding a short timeout (1-2 seconds) before running the query to rule out sync lag.
内容的提问来源于stack exchange,提问作者Marcelo Araujo

