Getting error in API request [SOLVED]


I am trying to request the mattermost API suing Angular JS + Nodejs + Gulp + Bower.
But I get below error

Please help me ASAP.

Thanks & Regards

Hi @ravidverve

If you go to the System Console -> Security -> Connections you’ll find an option to Enable cross-origin requests from a domain, if you set that then CORS is enabled and preflight of ajax requests work as expected, if you’re unsure what host to use then you can use * but I don’t recomend doing it that way.

If this solved your problem, can you be so kind to add a [SOLVED] in the thread title.

Thanks my friend

Hi @elias

Thanks for reply

I have checked that security settings and set the * for now, and try to call the API but now I get bad request error.
I have checked for bad request error and get this .
So in my case I am calling API from angular JS so can you help me to fix it.

Thanks & Ragards

Hi @ravidverve

Here’s an example with plain javascript

And as you can see here I have a valid response

I’ve have two possible solutions for you:

  1. check the version of the API that you are using, in your screenshot I see that you are using version 1 as in /api/v1 instead of version 3 like in my example. Version 3 is the current version of the API.
  2. Try and use out mattermost-driver-javascript as it has every API method in there.

Hope this helps.

Hi @ravidverve any luck solving this one?