Calling API through Azure Data Factory - azure-data-factory

I have to get the values of parameter by calling REST API. I need to fetch the parameters from database for which I need to get the value.
How can I pass the parameters from database.

You could use a Lookup activity to first query your database and get whatever value you want to get. You will be able to access this returned value in the lookup in your next steps. Parameterize your REST API linked service/dataset. You can pass in the value returned by the Lookup activity to this dataset parameter.
First, check if you are using firstRowOnly or your lookup is returning multiple rows. If it is returning multiple rows, you need to keep your next step in a forEach loop.
If your lookup activity is returning two rows, you get the output like shown below.
{
"count": 2,
"value": [
{
"enrollment_number": "123445"
},
{
"enrollment_number": "345678"
}
]
}
ADF Expression for URL would be this:
RemainingUrl/#{activity(activity_name).output.value.enrollment_number}

Related

Appsync how to use [String] inside query

I am trying to get products using specific brand names. I have set up my query as brandList : [String]
and the query is as follows
{
"terms": {
"brand_name":
$brandList
}
},
I am not sure how can I pass my query to Appsync. the original query should be like this
"["brand1","brand2","brand3"]". how can I handle the list of string with just brand name.
To be able to execute a query by filtering with an "in" operator it is only possible by using the enhanced filters (or by using the request mapping template).
I suggest you look here: https://docs.aws.amazon.com/appsync/latest/devguide/aws-appsync-real-time-enhanced-filtering.html

How to insert data into mongodb proper method

What is the proper way to insert data into mongodb? I am able to see other collection by nodejs api call but if i use below method data are inserted but i am not able to see the data on my nodejs api call.
So How to resolve this isse?
Here is my data:
db.trade.insert([
{
"p_id":"ot1",
"product_name":"Mixed",
"product_weight":"1kg",
"product_price":550,
"product_image":"rose.jpg"
},
{
"p_id":"ot2",
"product_name":"Mixed",
"product_weight":"1kg",
"product_price":550,
"product_image":"rose.jpg"
},
{
"p_id":"ot3",
"product_name":"Mixed",
"product_weight":"1kg",
"product_price":550,
"product_image":"rose.jpg"
}
]);
the insert() function takes a single document, while insertMany() takes an array of documents.
In your code, you're attempting to pass an array (multiple documents) into insert() (which expects a single document).
You could either make multiple calls to insert() or a single call to insertMany().

How to get item without hitting db twice iqueryable

For jquerydatatable, I need to prodive a json like this:
{
rusults:[],
count: 100
}.
Before actually hitting db, I have an iqueryable. Because I only get a specific number of per page, I have to use skip and take to get result (one request) and use another request to get item count for pagination.
Please tell me how could I avoid second request?

How to structure a limited query in AirTable

This is bringing back too much data,
https://api.airtable.com/v0/MyAccoutNumber/Movies?&api_key=MyKey
How can I just have it bring back the film names for instance. I have tried putting in various changes into the query but either an error occurs or the very same amount of data returns?
You can use the fields parameter to limit which fields are returned in the results. fields takes an URL-encoded array of field names or IDs.
For example, if you only want two fields called "Name" and "Year" returned in the results, the request would look like this:
/v0/appId/tableName?fields%5B%5D=Name&fields%5B%5D=Year
You can see jQuery.param as a reference for URL-encoding arrays and objects. In this case, jQuery.param({fields: ["Name", "Year"]) returns fields%5B%5D=Name&fields%5B%5D=Year.

Retrieving page_fans using FQL from Insights table

I m trying to retrieve the page_fans using the following FQL query (Insights Table).
SELECT metric, value FROM insights WHERE object_id=182929845081087 AND metric='page_fans' AND end_time=1334905200 AND period=86400
But I just get blank data , when I make the above query.
{
"data": [
]
}
I m able to retrieve the other metrics by just changing the metric value in the above query.
For Eg. I get the page_engaged_users by just changing the metric value in the above query.
SELECT metric, value FROM insights WHERE object_id=182929845081087 AND metric='page_engaged_users' AND end_time=1334905200 AND period=86400
{
"data": [
{
"metric": "page_engaged_users",
"value": 35
}
]
}
What is wrong with the first query in which I m trying to retrieve the page_fans ??
And I know that I can retrieve page_fans using other ways as well !!
If you look at the insights documentation, notice in the last column that the page_fans metric is only available for the lifetime period. Change your query to period=0 or `period=period('lifetime') and you'll get data.
If you want the new fans added on a given day, use the page_fan_adds metric with period('day').
If you request any other period, you will either get an error or no data (which means someone other than you can request that metric for a different period).
The other problem could be that you are requesting data that is too recent. In your query, you're looking at 2012-04-20, so you should be fine. When I tested this, I got no data if I used a date greater than 2012-09-15 (on 2012-09-18).