How to configure dynamic links for a Firebase project? - firebase-dynamic-links

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.

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!

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);
}
});

Related

API mocking in cypress intercept

I am new to cypress.
Problem: I am not able to intercept url for API mocking, when there are multiple APIs are appearing in console-> network tab
Description: My requirement is as follows:
login a website, after getting the landing page,go to a particular webpage, select multiple test cases check boxes
open console-> network tab , and click run
watch multiple APIs are coming
I selected one API url among them. I want to mock this particular one.
'GET'method , url (say: https://externalAPIurl) are copied in the following code
//verify landing page is reached
cy.contains("this is landing page").should("exist");
//after login open testcase page
cy.visit(
"https://example.com/testcases"
);
//go to test suite tab test suite
cy.get("#testsuiteid")
.click();
//click test suite name
cy.contains("testsuitename").click();
// select all test cases
cy.get(".testcasecheckbox")
.click();
cy.intercept(
{
method: "GET",
url: "https://externalAPIurl",
},
{
headers: {
authorization:
"AABBXXYY",
},
},
{
statusCode: 200,
body: [
{
status: 200,
result: true,
combination: [
//same data...
],
},
],
}
);
cy.get("#run_button").click();
});
Where am I wrong?
I checked in postman, the URL, with Get method and Header-> Authorization key with proper Authorization key value (as collected from network console Headers) giving correct response, but the cy.intercept is throwing error
How to solve this?
Whenever in a website we click a button, multiple external API s are visible in console-> network. If I take any one of them -> check the URL, method, header and getting the same response in postman as in the network console, I should be able to mock the same request URL.
I tried the same when one single API is appearing in network console. It was fine. But when I select one among multiple the result is an error.
Please note: I have included the header authorization, may be the format is wrong. But if I give or do not give the authorization, the result is the same error.
If you want to intercept a 'GET' and stub the response with predefined data. I would first use dev tools network tab to capture the api response you want. Copy the response and save as a json file in your fixture folder (you can edit this file as you see fit to fake the data how you wish). From there you can do the following:
cy.fixture('apiResponse.json').as('fixture data')
.then( (data) =>{
const raw = JSON.stringify(data)
cy.request( {
method : 'GET',
url : 'api url here',
headers : {
authorization : 'AABBXXYY',
},
body : raw
})
.then( (response) => {
cy.log(response.body)
expect(`Response.status = ${response.status}`).to.eq('Response.status = 200')
})
})

Change custromer-request-type in Jira ServiceDesk via REST API

I can receive the values of an created ticket using the SD API like:
GET /servicedeskapi/request/SD-4532
and within that i find something like:
{
"issueId": "71928",
"issueKey": "SD-4532",
"requestTypeId": "121",
"serviceDeskId": "5",
...
}
whereas "requestTypeId" related to the type created by the user (e.g. has a label "Common question").
Now i want to change the request type to, let's say "Hardware issue" which have the requestTypeId of "89".
When i try to change by POST /servicedeskapi/request/SD-4532
and giving a payload of
{
"requestTypeId": "89",
}
I get a "405 - Method not allowed". Also the Jira ServiceDesk REST-API doc does not state anything about a POST method for this.
So i tried the common Jira REST-API
PUT /api/2/issue/SD-4532
and give payload
{
"fields": {
"customfield_10001": {
"requestType": {
"id": "89"
}
}
}
}
but that give me an "Field 'customfield_10001' cannot be set. It is not on the appropriate screen, or unknown." error.
The reason why the Jira ServiceDesk REST API docs do not state anything about a POST method for this because.... there is no POST method for this. You cannot change a request (issue) type simply by altering the value of the field that contains the ID (metadata) of that request type.
Do a Google search on "jira rest api change issue type" to see the many other times this question has been discussed in the past in many places. In a nutshell, changing types is not possible via the REST API, only the web UI.
Use Jira Rest API to update Jira issue information. https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-put
// This code sample uses the 'node-fetch' library:
// https://www.npmjs.com/package/node-fetch
const fetch = require('node-fetch');
const bodyData = `{
"fields": {
"customfield_10010": "ABC-09",
"customfield_10000": {
"air": "",
"type": "doc",
"name": "Sample Process",
"avatarUrl": null
}
}
}`;
fetch('https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}', {
method: 'PUT',
headers: {
'Authorization': `Basic ${Buffer.from(
'email#example.com:<api_token>'
).toString('base64')}`,
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: bodyData
})
.then(response => {
console.log(
`Response: ${response.status} ${response.statusText}`
);
return response.text();
})
.then(text => console.log(text))
.catch(err => console.error(err));
email#example.com --> Your Jira emailid
<api_token> --> This is from your account token generated
Note:- Before using any API check if it's not experimental as this may cause issues in future due to sudden change in req/resp from Jira.
Try to inspect Jira dashboard network tab to understand more.

While trying to authenticate users in shopify, getting error: Field 'CustomerAccessTokenCreateInput' doesn't exist on type 'Mutation'

I am using node.js in my application, with shopify-api-node (v3.2.0), to authenticate customer login along with other features if shopify. As per shopify documentation (https://shopify.dev/docs/storefront-api/reference/mutation/customeraccesstokencreate) I am using GraphQL to access shopify API.
My code looks something like this below :-
const Shopify = require('shopify-api-node');
const shopify = new Shopify({
shopName: process.env.SHOPIFY_DOMAIN_NAME,
apiKey: process.env.SHOPIFY_API_KEY,
password: process.env.SHOPIFY_API_KEY_PASSWORD
});
const query = `mutation {
customerAccessTokenCreate (input: {
email: "user#mail.com",
password: "password123"
}
)
{
customerAccessToken {
accessToken
expiresAt
}
customerUserErrors {
code
field
message
}
}
}`;
shopify
.graphql(query)
.then((output) => {
console.log(output);
})
.catch((err) => {
console.error(err)
});
After this I am getting below error :-
Error: Field 'customerAccessTokenCreate' doesn't exist on type 'Mutation'
at got.then (/Users/admin/Documents/Code/shopify-node-app/node_modules/shopify-api-node/index.js:239:19)
at process._tickCallback (internal/process/next_tick.js:68:7)
locations: [ { line: 2, column: 5 } ],
path: [ 'mutation', 'customerAccessTokenCreate' ],
extensions:
{ code: 'undefinedField',
typeName: 'Mutation',
fieldName: 'customerAccessTokenCreate' }
Even I am getting the same thing from postman itself.
Any help would be appreciated.
There are two types of GraphQL:
the storefront GraphQL - https://shopify.dev/docs/storefront-api/reference
the admin GraphQL - https://shopify.dev/docs/admin-api/graphql/reference
While they seems similar the strorefront is much more limited but can be used on the front-end, while the admin one is more rich in method and functionality but can't be used safely on the font-end.
The documentation and the method you are trying to make is referring to the Storefront API, but the package you are using is for the Admin GraphQL API.
You can create a storefront access token via the storefrontAccessToken method if you want to make storefront request but the Admin API GraphQL allows for more customization.
So you need to make sure you are using the proper API.
If you plan to use the storefront API, you shouldn't use NodeJS and just create a private app ( from Admin -> APP -> Private App) which will provide you a Store Front Access Token (if you enable it at the bottom and select the proper scopes) that can be used directly on the front-end.
If you plan to use the Admin API, you will need to create a public app and host it, then you can use NodeJS and pass the information via a Proxy in Shopify.
Summary
You are making a request to the Storefront API, while using a library for the Admin API.

Cloud Recoding RESTful API Error of Agora.io

I would like to implement your Cloud Recoding of Live Broadcasting via RESTful API. I implemented it with NodeJs. Could you please help me why I get an error and how I can fix it?
On the manual,
"Status Code 400: The input is in the wrong format."
But I do not know what is wrong.
error: null
body: { resourceId: '', code: 400 }
var plainCredentials = new Buffer.from(agoraCustomerId+":"+agoraCustomerCertificate);
var base64Credentials = plainCredentials.toString("base64");
var options = {
url: "https://api.agora.io/v1/apps/AGORA_APP_ID/cloud_recording/acquire",
method: "POST",
headers: {
"Authorization": "Basic " + base64Credentials,
"Content-type": "application/json;charset=utf-8"
},
body:{
"cname": "190724060650293",
"uid": "060716332",
"clientRequest": {}
}
};
request.post(options, function (error, response, body) {
console.log("error: " + error);
console.log("body: ", body);
});
Agora's Cloud Recording is an add-on feature so it's not enabled by default, it needs to be enabled on your account for a specific AppID. The error you may be receiving is because the feature is not enabled on your account.
UPDATE:
Enabling Agora.io's Cloud Recording on your project is now available through the Agora.io Dashboard.
To enable Cloud Recording on your project, you’ll need to click into the Products & Usage section of the Agora.io Dashboard and select the Project name from the drop-down in the upper left-hand corner, click the Duration link below Cloud Recording.
After you click Enable Cloud Recording, you will be prompted to confirm the concurrent channels settings which defaults to 50, but you can contact sales#agora.io if you need more.
Theres a getting started tutorial that leverages a POSTMAN collection for quick testing.
QuickStart Tutorial: https://medium.com/#hermes_11327/agora-cloud-recording-quickstart-guide-with-postman-demo-c4a6b824e708
Postman Collection: https://documenter.getpostman.com/view/6319646/SVSLr9AM?version=latest
In my case it was mistake in Region settings . I used AP_NORTHEAST_1 but 10 need be used
1 - Make sure you have enable agora recording
2- Check the link and send all parameters.
https://docs-preprod.agora.io/en/cloud-recording/cloud_recording_webpage_mode?platform=RESTful
EX: {
"cname": "httpClient463224",
"uid": "527841",
"clientRequest":{
"resourceExpiredHour": 24,
"scene": 1
}
}
You forgot to put "resourceExpiredHour": 24,"scene": 1
More info:
PHP: you need to put strval function
$body = ["cname"=>strval($cname),"uid" =>strval($uid),"clientRequest" => ["resourceExpiredHour" => 24,"scene" => 1]];
I hope you solve your issue

Using the Rally API to pull user profile

I am trying to use the Rally web service API to get some data. Code as blow. On IE it will pop out a login window, after entry login name and password, I am about to get some data. But when I use chrome, it response 401, not sure what I missing. I know there is SDK available, but due to some limitation, not able to use it. Any suggestions please?
var url = https://rally1.rallydev.com/slm/webservice/v2.0/users;
$.ajax({
url: url,
type: 'GET',
heards: { zsessionid: apiKey },
success: function(json) {
console.log(JSON.stringify(json));
}
},
error: function( req, status, err ) { console.log( 'something went wrong', status, err );
}
});
I'd love to know more about why you can't use the SDK. Anyway, in this case your config likely needs headers instead of heards to pass the api key.