# Getting response from a RESTful Go service

**URL:** <https://discuss.elastic.co/t/getting-response-from-a-restful-go-service/214602>\
**Category:** Kibana\
**Tags:** docker\
**Created:** [January 10, 2020, 1:32pm UTC](https://discuss.elastic.co/t/getting-response-from-a-restful-go-service/214602 "2020-01-10T13:32:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ali\_Muhammad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ali_muhammad/32/43530_2.png) [@Ali\_Muhammad](https://discuss.elastic.co/u/Ali_Muhammad)\
**Post date:** [January 10, 2020, 1:32pm UTC](https://discuss.elastic.co/t/getting-response-from-a-restful-go-service/214602/1 "2020-01-10T13:32:24Z")

</div>

Hi Community.  
So, i have been trying to request from my Go service using Ajax/fetch with the kibana plugin Js file but so far no luck. I get a `405 (method not allowed)` error.

request:  
`fetch('https://somelink/createinfo', { mode: 'no-cors'}, { headers: { 'Content-Type': 'application/json' }, method: "POST", body: jsonsjson }) .then(res => res.text()) .then(console.log)`

On Go service I have added the following header.

`w.Header().Set("Access-Control-Allow-Origin", "*")`  
`w.Header().Set("Access-Control-Max-Age", "3600")`  
`w.Header().Set("Access-Control-Allow-Credentials", "true")`  
`w.Header().Set("Access-Control-Allow-Headers", "Access-Control-Allow-Headers, Access-Control-Allow-Methods, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers")`  
`w.Header().Set("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT,DELETE")`

The service responds just fine on POSTMAN with no additional headers. Also, the setup is present on k8s and I am using ingress to expose the service securely.

Any help here wil be great. thanks!

---

<div class="post-metadata">

**Author:** ![joshdover](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdover/32/42020_2.png) [@joshdover](https://discuss.elastic.co/u/joshdover)\
**Post date:** [January 10, 2020, 11:12pm UTC](https://discuss.elastic.co/t/getting-response-from-a-restful-go-service/214602/2 "2020-01-10T23:12:59Z")

</div>

I believe you will need the `mode` set to `cors` instead of `no-cors`.

---

<div class="post-metadata">

**Author:** ![Ali\_Muhammad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ali_muhammad/32/43530_2.png) [@Ali\_Muhammad](https://discuss.elastic.co/u/Ali_Muhammad)\
**Post date:** [January 30, 2020, 11:12am UTC](https://discuss.elastic.co/t/getting-response-from-a-restful-go-service/214602/3 "2020-01-30T11:12:54Z")

</div>

Hi Josh thanks for the response.  
I am now using XMLHttpRequest() will end to end cors enabled and that works fine. It even worked with an insecure connection unlike the ajax call.

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 27, 2020, 11:13am UTC](https://discuss.elastic.co/t/getting-response-from-a-restful-go-service/214602/4 "2020-02-27T11:13:00Z")

</div>

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