HTTPs request not working for mobile plugins

In my plugin, I make a request using obsidian.request api. This works on desktop, however the API request fails on mobile (Android) giving me this error.

here is my code that makes the request:

const getAllNotesFirebase = async (email: string, password: string) => {
  let notes = [];
  try {
    const body = {
        'email': email,
        'password': password,
    }
    const config = {
        method: 'post',
        url: 'https://us-central1-fleetingnotes-22f77.cloudfunctions.net/get_all_notes',
        contentType: 'application/json',
        body: JSON.stringify(body),
    };
    const res = await request(config);
    notes = JSON.parse(res);
  } catch (e) {
      console.log(e);
      throw 'Failed to retrieve notes from the database - Check credentials in settings & internet connection';
  }
  return notes;
}

If i remove the “body” field in the request it works. That being said, it’s odd that we can’t send a request with a body in mobile…

1 Like

Did you solve the problem with http-request in obsidian for android ?

I ended up using an SDK to make it work. Haven’t found a solution unfortunately :frowning:

Try changing post to POST. HTTP request methods should be capitalised, and some platforms are strict about it.

Works for me at least on Android with that one change.

1 Like

I use now for a body-Post in JSON-Format and it is working on Desktop and Android


const options: RequestUrlParam = {
			url: URL,
			method: 'POST',
			headers: {
				"content-type": "application/json"
			},
			body: JSON.stringify(jsontest)
		}

response = await requestUrl(options)
1 Like