[Bug] Firebase Functions - GetHttpsCallable actually sends a POST request, should be renamed

Open
#1,233 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, typescript, unity

Research direction

Review the GetHttpsCallable entry point in the C# file and the api.get/api.post routes shown in index.ts. Confirm the callable request behavior and identify the public method references that would need consistent naming. Done means the method name accurately reflects the POST-only behavior and the documented usage no longer suggests GET.

Written by the indexing model from the issue text.

Description

api: functions type: feature request
[REQUIRED] Please fill in the following fields:
  • Unity editor version: 2021.1.17f1
  • Firebase Unity SDK version: 8.8.0
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: Functions
  • Other Firebase Components in use: Auth, Firestore
  • Additional SDKs you are using: N/A
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: Android
  • Scripting Runtime: IL2CPP
[REQUIRED] Please describe the issue here:

I am using Firebase Functions with Express routing set up, e.g. in my index.ts file (external to the Unity project):

api.get("/products", helloWorld);

When I call this route within my Unity project, using GetHttpsCallable in a C# file:

var func = _firebaseFunc.GetHttpsCallable("api/products");

It turns out a POST request is sent by default (using SmartSniff)
image

From reading about this (StackOverflow 1, 2) it seems this is intended behaviour - Firebase cloud functions indeed only accept POST requests: https://firebase.google.com/docs/functions/callable-reference

However, it would certainly solve a lot of headaches if the SDK method call did not begin with the word 'GET'. The only error message I was able to get was 'INTERNAL' in the Unity editor, or 'Not Valid JSON' when building to device, and as a result took some time to debug.

After creating a duplicate route with 'post' alongside my 'get' route, the call began to work as expected:

api.get("/products", helloWorld);
api.post("/products", helloWorld);
Steps to reproduce:

As above

Relevant Code:

As above

Dominant language
C#
Stars
923
Forks
456
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/quickstart-unity

All issues in firebase/quickstart-unity

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.