10

Since google is shutting down it's url shortening service, I want to move my project to FDL.

I am using the api to shorten the url following this: https://firebase.google.com/docs/dynamic-links/rest#create_a_short_link_from_a_long_link

and I am using Postman to call the api but I keep getting this error.

{
"error": {
    "code": 400,
    "message": "Your project has not configured Dynamic Links. [https://firebase.google.com/docs/dynamic-links/rest#before_you_begin]",
    "status": "INVALID_ARGUMENT"
}
}

I am using the correct api key and the project id.

Mubashar Abbas
  • 5,536
  • 4
  • 38
  • 49

2 Answers2

0

Had the same issue- and thats the answer i got from the firebase team:

Take note that to be able to view your Dynamic Link domain you'll have to add an app first. If you're using Firebase Dynamic Link as a substitute to Google Shortener, you can create a sample application (dummy app) for your project to proceed creating a Firebase Dynamic Links. Just enter dummy values for the iOS bundle ID or Android package name (ex: “my.dummy.app”) to continue.

then you'll put the id you'll get from it (e.g. https://dedfgu.app.goo.gl) instead of the place holder (https://abc123.app.goo.gl).

Good luck!

DasDas
  • 571
  • 3
  • 9
  • 32
  • okay i tried with a dummy add, and that error went away but I am getting an internal server error now.. not very descriptive. { "error": { "code": 500, "message": "Internal error encountered.", "status": "INTERNAL" } } – Mubashar Abbas Apr 18 '18 at 07:53
  • @MubasharAbbas you getting the error from firebase? can you post your full ajax request? – DasDas Apr 18 '18 at 08:07
  • 1
    it's not an ajax request.. i am doing it via postman.. https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key={{api_key}} i think this is a hard error, doesn't sound like google at all. – Mubashar Abbas Apr 18 '18 at 10:23
  • I have the same problem, even if I use firebaseio.com instead of app.goo.gl – Phil C Apr 23 '18 at 09:26
  • @CarneyCode did you create a dummy app(android/ios) at firebase? – DasDas Apr 23 '18 at 09:58
  • @DasDas Yes, and put this in the body: { "longDynamicLink": "https://{ProjectID}.firebaseio.com/?link=https://example.com/&apn=dummy.app.android&ibi=my.dummy.app" } – Phil C Apr 23 '18 at 10:00
  • @CarneyCode why not https://{ProjectID}.app.goo.gl? and do you get the same error? – DasDas Apr 23 '18 at 10:04
  • @DasDas That gives the following error: { "error": { "code": 400, "message": "Your project does not own Dynamic Links domain: https://slateppi.app.goo.gl [https://firebase.google.com/docs/dynamic-links/rest#create_a_short_link_from_parameters]", "status": "INVALID_ARGUMENT" } } – Phil C Apr 23 '18 at 10:05
0

You can try following way

var Url = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key={API-Key}";

 $.ajax({
        type: 'POST',
        dataType: 'json',
        url: Url,
        contentType:'application/json',
        data: JSON.stringify({
            "dynamicLinkInfo": {
                "domainUriPrefix": "https://newxpress.page.link",
                "link": {Your-Link},
                "androidInfo": {
                    "androidPackageName": "com.newxpress"
                },
                "iosInfo": {
                    "iosBundleId": "com.newxpress.iosapp"
                }
            }
        }),
        success: function (jsondata) {
            console.log(jsondata);
        },
        error: function (result) {
            console.log(result);
        }
    });