New .api Freshchat API endpoints behaving differently to documentation

There appears to be some differences in the way the Freshchat API behaves with these new url access points (.api.freshchat) to the previous ones (.subdomain.freshchat). I am having trouble using the conversations end point in postman to get conversation details or post messages to it but I am using exactly the same methods as I use with the old url.

Here are some examples:

https://api.eu.freshchat.com/v2/conversations/:conversation_id

returns the following even though I captured the conversation ID via the console from an installed custom app.

{
    "code": 404,
    "status": "CONVERSATION_NOT_FOUND",
    "message": "Conversation Not Found"
}

Also when trying to post a message to a chat with a stringified payload in the body I get the following error with the new urls. I tried to get this to work in postman and it suggested the end point doesn’t like the payload.

'{"code":400,"status":"INVALID_VALUE"}'

Any chance of an online session to look at this as this all worked fine against the old url access point.

1 Like

Hey @RobAtOpinyin !
you are probably getting this error because you sending the wrong conversation id, thsi part is missing in docs. iin case you need to get right conversation id try my code sample:

function getConversation() {
  client.data.get('conversation').then(
    function (payload) {
      console.log(payload)
      };
    },
    function (error) {
      console.error('Failed to get conversation details');
  
    }
  );
}

Hi @Nasir_Haidari

Thanks for this. The conversation ID I used was captured by logging the ID from onConversationUpdate event in a serverless app. It was provided directly in the payload provided with this event by Freshchat.

@RobAtOpinyin
here is a screenshot from my postman and it works fine both with POST and GET request! as i mentioned earlier i think you are sending wrong conversation id…

Hi @Nasir_Haidari

Thanks for that. Its good to have confirmation I am not doing anything wrong. I will check the conversation ID

Hi @Nasir_Haidari

Do you know a quick way of getting a conversation ID without having to code it. My app doesn’t have an client side app and I don’t really want to add one.

Thanks in advance.

Unfortunately not, the only way I know is via client.

Regards,
Nasir Haidari

Thanks for your inputs, @Nasir_Haidari!

@RobAtOpinyin How are you fetching the conversation ID currently? I see from the docs for the onConversationCreate event that you should expect a data.conversation.conversation_id.

If you think you are getting the wrong conversation ID in the serverless event payload using the same method, please let me know. We might need to flag it as a bug.

@kaustavdm

I have tested this and the convesation ID that comes from data.conversation.conversation_id in the onConversationUpdate event payload when used with the following API call:

https://api.eu.freshchat.com/v2/conversations/:conversation_id

returns a 404 error and the following message:

{
    "code": 404,
    "status": "CONVERSATION_NOT_FOUND",
    "message": "Conversation Not Found"
}

Hi @kaustavdm

Is there any update on this? I need to get this app to a customer.

Thanks

Sorry about the delay here, @RobAtOpinyin.

I assume the account is in the EU region.

Can you book an office hour with me through this link: Calendly?

No problem. Yes that is the region I am testing with but I am not sure if it is the same with the other regions as I can’t test those.

1 Like

@Utkarsh_Singh @Ganesh_Balaji FYI Rob’s issue occurs only in bundled accounts. Can you let us know what should be the base URL for calling bundled Freshchat account REST API?

Hi @kaustavdm

I tested the automation app in the merged product and it worked as expected. I am going to retest my app to see what happens.

Hi @kaustavdm

I am not sure what you guys did but everything is now working as expected in the merged product and the pre merged version :clap: :smiley: :partying_face:

Many thanks guys for sorting this.

@Ganesh_Balaji @Utkarsh_Singh

Thanks for the updates, @Rob. Glad to know it works now, though I am pretty sure we did nothing on our end to sort it. We were trying to find out how to find the API base URL information for bundled Freshchat accounts.

Did you finally use the *.myfreshworks.com domain?

Hi @kaustavdm

No. I used api.eu.freschat.com. I suspected something was being worked on yesterday as the developer portal went down for a while, but I think that may have been the rollout of the ‘In testing’ feature. I should add that this base also works on non bundled accounts as well.

I now run a small bit of discovery code to identify the correct base url. If its not the right one of the 4 AWS locations of your instance, you get a 400 status and the following message

{
    "success": false,
    "error_code": 0,
    "error_message": "java.lang.RuntimeException: Token not present"
}

If it the token is not recognised then you get a 400 status and the following message irrespective of the base url used.

{
    "success": false,
    "error_code": 0,
    "error_message": "Unable to read JSON value: _\"kid\":\"custom-oauth-keyid\",\"typ\":\"JWT\",\"alg\":\"HS256\"}"
}

This process is a bit nasty so it would be nice to have the appropriate base url in the iparams of the event payload and in the client object. This would then remove the need to try and discover it on install.

3 Likes

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