Kobotoolbox REST services

Hi everyone,
I want to access the kobotoolbox REST services from my web (react web app) but when acesing the end-point I get a ‘Access-Control-Allow-Origin’ error.

login = (username, password) => {

const headers = new Headers()

headers.set(

‘Authorization’,

'Basic ’ + Base64.encode(username + ‘:’ + password)

)

fetch(‘https://kc.humanitarianresponse.info/token/?format=json’, {

method: ‘GET’,

headers: headers

}).then(response => response.json())

}

Where can I find an example to access the REST services from web?

I am completely new with kobotoolbox and I am sure I am doing something completely wrong.

Thanks!

Iván

Hi Ivan,

You need to change the subdomain to ‘kobo’ instead of ‘kc’. This token is provided by the kpi application, which is the new default API service.

···

On Sat, Oct 20, 2018 at 4:20 AM Iván Navarro 75 ivan.na...@gmail.com wrote:

Hi everyone,
I want to access the kobotoolbox REST services from my web (react web app) but when acesing the end-point I get a ‘Access-Control-Allow-Origin’ error.

login = (username, password) => {

const headers = new Headers()
headers.set(

‘Authorization’,

'Basic ’ + Base64.encode(username + ‘:’ + password)

)

fetch(‘https://kc.humanitarianresponse.info/token/?format=json’, {

method: ‘GET’,

headers: headers

}).then(response => response.json())

}

Where can I find an example to access the REST services from web?

I am completely new with kobotoolbox and I am sure I am doing something completely wrong.

Thanks!

Iván

You received this message because you are subscribed to the Google Groups “KoBoToolbox Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.

Visit this group at https://groups.google.com/group/kobo-users.

For more options, visit https://groups.google.com/d/optout.

Hi Tino,
thanks for you answer, I’ve just modified the URL for this one https://kobo.humanitarianresponse.info/token/?format=json and still receiving the same error.

Failed to load https://kobo.humanitarianresponse.info/token/?format=json: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:3000’ is therefore not allowed access. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

Regards,

Iván

···

El lun., 22 oct. 2018 a las 15:18, Tino Kreutzer (tino.k...@kobotoolbox.org) escribió:

Hi Ivan,

You need to change the subdomain to ‘kobo’ instead of ‘kc’. This token is provided by the kpi application, which is the new default API service.

On Sat, Oct 20, 2018 at 4:20 AM Iván Navarro 75 ivan.na...@gmail.com wrote:

Hi everyone,
I want to access the kobotoolbox REST services from my web (react web app) but when acesing the end-point I get a ‘Access-Control-Allow-Origin’ error.

login = (username, password) => {

const headers = new Headers()
headers.set(

‘Authorization’,

'Basic ’ + Base64.encode(username + ‘:’ + password)

)

fetch(‘https://kc.humanitarianresponse.info/token/?format=json’, {

method: ‘GET’,

headers: headers

}).then(response => response.json())

}

Where can I find an example to access the REST services from web?

I am completely new with kobotoolbox and I am sure I am doing something completely wrong.

Thanks!

Iván

You received this message because you are subscribed to the Google Groups “KoBoToolbox Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.

Visit this group at https://groups.google.com/group/kobo-users.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to a topic in the Google Groups “KoBoToolbox Users” group.

To unsubscribe from this topic, visit https://groups.google.com/d/topic/kobo-users/vzk1eyD0U0Q/unsubscribe.

To unsubscribe from this group and all its topics, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.

Visit this group at https://groups.google.com/group/kobo-users.

For more options, visit https://groups.google.com/d/optout.