Update Project Label Text via Dynamics API - api

I'm using the dynamics CRM REST API to create projects, and manage some actions on Microsoft Projects online.
We're using labels, which we can apply to tasks, to signify various things.
Via the API I can read labels, and I can read and write the labels that have been assigned to each task (msdyn_projecttask).
The bit I haven't succeeded with is creating an API call which will change the text of a label from the default (Pink, Red, Yellow etc.) to something more useful.
Currently I'm having to manually edit the label text via the Project User Interface (e.g. see below).
Once I've renamed the label, when I fetch them via the API I can see the changed text, but I can't figure out a way to change it via the API.
I'm able to fetch the project labels via
GET https://orgXYZABC.api.crm4.dynamics.com/api/data/v9.1/msdyn_projectlabels?$filter=_msdyn_projectid_value%20eq%20%27{projectId}%27
(where {projectId} is the msydn_projectid of my project)
Which returns data like:
{
"#odata.context":"https://orgXYZABC.api.crm4.dynamics.com/api/data/v9.1/$metadata#msdyn_projectlabels",
"value":[
{
"#odata.etag":"W/\"21783358\"",
"_owningbusinessunit_value":".....",
"statecode":0,
"msdyn_colorindex":192350000,
"statuscode":1,
"_createdby_value":"....",
"_ownerid_value":".....",
"_owningteam_value":".....",
"modifiedon":"2022-11-02T13:32:26Z",
"_modifiedby_value":"....",
"versionnumber":21783358,
"_msdyn_projectid_value":".....",
"createdon":"2022-11-02T13:32:26Z",
"msdyn_projectlabelid":"625eb1b2.....",
"_owninguser_value":null,
"overriddencreatedon":null,
"importsequencenumber":null,
"_modifiedonbehalfby_value":null,
"msdyn_projectlabeltext": "Label One",
"utcconversiontimezonecode":null,
"_createdonbehalfby_value":null,
"timezoneruleversionnumber":null
},
....
]
}
I've tried:
PATCH https://orgXYZABC.api.crm4.dynamics.com/api/data/v9.1/msdyn_projectlabels({labelId}})
(where {labelId} is one of the msdyn_projectlabelid values returned above)
headers: [
"If-Match: *",
"OData-MaxVersion: 4.0",
"OData-Version: 4.0",
"Accept: application/json",
"Authorization: ...",
"Content-Type: application/json; charset=utf-8"
]
body: {
"msdyn_projectlabeltext": "Test Label 1"
}
But it fails and says:
"We\u2019re sorry. You cannot directly do 'Update' operation to 'msdyn_projectlabel'. Try editing it through the Resource editing UI via Project."
And I've tried:
PATCH https://orgXYZABC.api.crm4.dynamics.com/api/data/v9.1/msdyn_projectlabels
headers: [
"If-Match: *",
"OData-MaxVersion: 4.0",
"OData-Version: 4.0",
"Accept: application/json",
"Authorization: ...",
"Content-Type: application/json; charset=utf-8"
]
body: {
"msdyn_projectlabeltext": "Test Label 1"
"msdyn_projectlabelid#odata.bind": "/msdyn_projectlabels({labelId})"
}
Which fails, saying:
"The requested resource does not support http method 'PATCH'."
Also tried:
PUT https://orgXYZABC.api.crm4.dynamics.com/api/data/v9.1/msdyn_projectlabels({labelId})/msdyn_projectlabeltext
headers: [
"OData-MaxVersion: 4.0",
"OData-Version: 4.0",
"Accept: application/json",
"Authorization: ...",
"Content-Type: application/json; charset=utf-8"
]
body: {
"value": "Test Label 1"
}
Which fails with the same error as above.
There doesn't seem to be any documentation for this anywhere, if you google "msdyn_projectlabel" or "msdyn_projectlabels" (in quotes) you don't get a single result!
Anyone out there have any knowledge on whether this is possible / how to succeed?

Related

Strava API: Create muted activity

Using Strava API v3 and create activity method, I'd like to mute activity. So, according to the docs, I should set hide_from_home to true.
However, the flag doesn't work correctly. Meaning, I'm receiving response containing:
"hide_from_home": false
And, activity is visible in Active Feed.
I tried to send the request via Flurl (C#) and curl (Postman).
The Flurl code looks more like a:
var rs = await host.AppendPathSegments("activities")
.WithOAuthBearerToken(accessToken)
.AllowAnyHttpStatus()
.PostUrlEncodedAsync(new Dictionary<string, dynamic>
{
{ "name", "😎 test from api" },
{ "type", "Walk" }, // https://developers.strava.com/docs/reference/#api-models-ActivityType
{ "sport_type", "Walk" }, // https://developers.strava.com/docs/reference/#api-models-SportType
{ "start_date_local", DateTime.Now.AddMilliseconds(-1).ToString("s", CultureInfo.InvariantCulture) },
{ "elapsed_time", 2 }, // In seconds
{ "hide_from_home", true },
})
.ReceiveString();
I tried to use dynamic, object and string as a dictionary value type and tried to pass true (as a boolean) and "true" (as a string), but none of these worked.
For curl, I imported example from the Strava Playground (Swagger UI) [Authorization removed in that example]:
curl -X POST "https://www.strava.com/api/v3/activities" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "name=Api&type=Walk&sport_type=Walk&start_date_local=2022-08-12&elapsed_time=2&hide_from_home=true"
So, the question: How to create muted activity via Strava API?

API Authentication issues from bubble to claifai

I have built a Bubble App and need to integrate it with a application custom model I am building in Clarifai but when I use the Bubble API plugin to connect to do an image predict it says I have an authentication issue 10002
Bubble API header details
Bubble POST call
what am I doing wrong???
Please try using the following cURL command and replacing it with your variable. I have tested it on my side and it works. As for the Bubble issue, that is something you would need to contact their Support about. We are not sure how they are processing their requests but Bubble doesn't seem to able to handle API calls from Clarifai.
curl -X POST \
-H "Authorization: Key YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '
{
"inputs": [
{
"data": {
"image": {
"url": "https://samples.clarifai.com/metro-north.jpg"
}
}
}
]
}'\
https://api.clarifai.com/v2/models/{YOUR_MODEL_NAME}/outputs

Error 401 on POST Request in Loopback

Good morning, guys. I'm still new to Loopback, and have a feeling that I'm missing something, but not sure where and what to find, so advice would be helpful.
I have an app. I'm using local authentication with standard ACL.
I have few methods that open only for $owner, and few that open for $authenticated. I'm using few POST requests within the app to retrieve data, and every time I get 401 error. If use GET request, all I have to do is to include an access token id into the url like that url?access_token=jjkdfsjjkj334.
I have a feeling that there is a some sort similar of trick for POST requests.
Any help would be appreciated.
For the post request pass the access_token as the "Authorization" header in the respective post call.
request({url: url, json: true, headers: {'Authorization': 'access-token-value'}}, function (err, res, responseJson) {
console.log(responseJson);
});
You also specify other headers also, like Accept-type etc.
If you had a model called Test with the following ACL:
{
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
},
{
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW",
"property": "create"
}
You should be able to make the following POST request:
curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "{}" "http://localhost:3000/api/Tests?access_token=cor7DDfUKoFSI6DzgCezQzoKFOuSmpLYzSF85xA8QXePkbFAGDKjjp7QwaVlP11B"
I always like to use the component explorer to test out what works and what doesn't. My guess is that something isn't set up properly in your ACL.

How to list only assignable video categories youtube v3?

Using v2 of the API via: http://gdata.youtube.com/schemas/2007/categories.cat, I can see both assignable and deprecated video categories.
However, using the v3 google data API, I see all categories, but no flag indicating if they are usable as a category on a video upload. Case in point is the category labelled "Anime/Animation" (category 31). If you try to upload a video using this category, you will receive a "Bad Request" response from YT at the end of the upload process.
If you choose any of the categories in the "assignable" list as per the first URL, then the upload works. Here's a deprecated category using the Atom based API:
<atom:category term="Movies_anime_animation" label="Anime/Animation" xml:lang="en-US">
<yt:deprecated/>
</atom:category>
Here's the same thing, in JSON, from the Google API Explorer:
{
"id": "31",
"kind": "youtube#videoCategory",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/-p_eJg3ji5PiNMcZrzS4hNfl4gQ\"",
"snippet": {
"channelId": "UCBR8-60-B28hp2BmDPdntcQ",
"title": "Anime/Animation"
}
I've looked at the video.list v3 API docs, and also the raw JSON output from the same API. I can't see how I could differentiate between deprecated and assignable categories. Is this just plain missing from the API or have I missed something?
You can receive the list of assignable categories parsing XML document. This is an example on PHP:
$catURL = 'http://gdata.youtube.com/schemas/2007/categories.cat';
$cxml = simplexml_load_file($catURL);
$cxml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
$result = $cxml->xpath('//atom:category/yt:assignable/..');
$categories = array();
foreach ($result as $row) $categories[(string)$row['term']] = (string)$row['label'];
For anyone who stumbles upon this question: YouTube V3 API now returns an assignable flag with each category snippet.
Request
curl \
'https://www.googleapis.com/youtube/v3/videoCategories?part=snippet&regionCode=NL&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
Response
{
"kind": "youtube#videoCategory",
"etag": "7mqChSJogdF3hSIL-88BfDE-W8M",
"id": "17",
"snippet": {
"title": "Sports",
"assignable": true,
"channelId": "UCBR8-60-B28hp2BmDPdntcQ"
}
}

how set ajax call by rest api parse.com

I'm new in rest api and i'm trying to use the api rest to associate file to object:
curl -X POST \
-H "X-Parse-Application-Id: qS0KL*9lFLE**S3VMk" \
-H "X-Parse-REST-API-Key: nh3***MhcKJIfIt1Gm" \
-H "Content-Type: application/json" \
-d '{
"name": "Andrew",
"picture": {
"name": "...profile.png",
"__type": "File"
}
}' \
https://api.parse.com/1/classes/PlayerProfile
Can anyone explain me how to set the ajax call?And what is "name":"andrew"?Is this a column named andrew in my player profile?
This is my implementation of api,but the server responded me bad request 400:
$.ajax({
type: 'POST',
headers: {'X-Parse-Application-Id':'qS0KLMx5h9lFLG**yhM9EEPiTS3VMk','X-Parse-REST-API-
Key':'nh3G8D**hcKJIfIt1Gm','Content-Type': 'application/json'},
url: "https://api.parse.com/1/users",
data: {
"username": "francesco",
"picture": {
"name": "b3b47ce2-62dc-4861-a0ad-79cfffe9b07a-foto ste.jpg",
"__type": "File"
}
},
contentType: "application/json",
success: function(data) {
console.log(data );
},
error: function(data) {
console.log("ko" );
}
});
May the api -d is wrong in my implementation.What's means -d in curl?
The example in the guide shows how you can create a new PlayerProfile object and associate it with a File in a single request. Since you want to update an existing User (and not create a new one), you'll need to use the Update REST API request format. Use PUT instead of POST, then specify which user you're referring to by appending the object id to the endpoint URL: https://api.parse.com/1/users/{objectId}.