Get some user's team with Jira Rest API by their accountId - javascript

I'm using the JIRA rest API in order to get the team of some user by passing their accountId as a parameter in the URL, for example:
URL = "https://my_account.atlassian.net/rest/api/3/user?accountId="+userId+"/team"
But I'm getting the error: "404 item not found".
Does anyone have any idea how I could get what I need?
I'm developing with Google App.Script, but the programming language does not matter if someone has some useful idea.
Thanks!

Firstly, you're forming the query incorrectly. You can't add parameters after the '?' using a forward slash because the forward slash is used for hierarchy in the URL.
Secondly, there is no endpoint 'team' and there currently is no mechanism provided by the Jira REST API to lookup what Team a user is a member of. Refer to this thread on the Atlassian community.

Related

How to search an api that does not have a search page?

Say, I have the api api.example.com, and it has a page under api.example.com/view/${id} that takes an id and returns json data like so:
{
title: "foobar",
id: 34102
}
The api does not have a search page.
The possible ids starts from 00001 to 99999. How can I search for "foobar" and get back 34102?
The only option I can think of is storing all that data through web scraping then searching in it. But sending 100000 requests would most likely get my IP banned.
Thanks.
I haven't tried anything yet.
Unfortunately if the website providing the API does not also provide an API with a keyword search, you won't be able to find it by that parameter. They are their API routes and they can handle the logic and parameters as they choose, so if they don't want you searching by a title, you're out of luck.
Keep in mind that your alternative solution is not something that you should do -- You should not hit someone's API with 1k+ requests.

401 Unauthorized API

I've stumbled upon a problem whilst working on a weather app. I have 401 error popping up every time i'm trying to fetch API from openweathermap.com. I've tried everything so far to fix this problem like waiting some days until my API key would work for me. I also tried to create a new API key and use it but failed at it again. Finally i tried to create another account on openweathermap.com but still have this error. Can anyone help me to find out what is the problem?
P.S. i used a valid API for checking a basic weather info that is available for free subscribtion.
401 Error screenshot
Your API Key is provided as a value to query parameter: appid is wrapped in {}. Remove those braces and perform the request again.
Very often, you will find the usage of {} in the documents, they represent placeholders in a string and are not meant to be part of the final string.
Weathermap Docs: How to make an API Call?
Also, please, make sure that you DO NOT share any essential API Keys in a public forum.
{} should be removed inside the url. It should be
let api = `https://api/openweathermap.org/data/2.5/weather?q=${city}&appid=e2850163218373000f889c28107ac0cf`

Unable to delete comment using Facebook Javascript SDK - use right access-token

I'm trying to delete a comment using a Graph API call.
https://graph.facebook.com/[comment-id]?access_token=[access-token]&method=delete
However, in terms of access-token, I'm not sure which one to use? I have used my App's "User Access Token", "Page Access Token" and "App Token". It doesn't work for any of these.
[PS, my app has all permissions, and I have even submitted it for review]
I just wanted to know if it was even possible to delete a comment which was not posted by the application? (Because I see that Delete is only allowed for page access tokens).
So, please do let me know if it is possible to delete a comment from a user's posts. And if so, which access_token to provide.
The docs list all the neccessary Access Tokens and permissions:
https://developers.facebook.com/docs/graph-api/reference/v2.10/comment#deleting
I tried it with a user profile, it does not seem to be possible to post comments or delete them - no matter if was created by the App or manually:
Publishing comments through the API is only available for page access
tokens
For Pages, you need to use a Page Tokens with the neccessary permissions according to the docs.
It looks to me that you're doing an HTTP GET call and just putting &method=delete at the end. That's not how it works
You should do an HTTP DELETE call. So instead of doing something like $.get(...), you should do $.ajax with type: 'DELETE'
Also, make sure your token has publish_actions permission

How can i get access token by using Client Id and client secret

I have practiced getting for access token by using Temboo on authorization Url and callback id. But after using this callback id get error like "A Server Error has occurred: The specified object doesn't exist or you don't have the necessary permissions to access it. The error occurred in the Expression (Get callback data) step.". I am not getting how approach this issue. Thank you.
I work for Temboo.
The best place to start with Foursquare OAuth is by watching the short screencast below that explains everything you need to know about how Temboo simplifies OAuth. The video discusses working with the Fitbit API, but once you know how that one works you'll be able to use the Foursquare API in exactly the same manner.
http://www.temboo.com/videos#oauthchoreos
Setup instructions for the Foursquare OAuth Choreos can also be found here:
https://temboo.com/library/Library/Foursquare/OAuth/
Hopefully this helps, but feel free to contact us via email (support AT temboo.com) if you have further questions - we're always happy to help.

RESTful API design with associations

I'm attempting to build an API for two resources, one with Users, and the other with Movies. Both resources have associations -- a User will have multiple Movies, and a Movie will have multiple Users. Presumably, I'd design my API something like this:
/api/users/
/api/users/:id
/api/users/:id/movies
/api/movies/
/api/movies/:id
/api/movies/:id/users
But here's the issue: I'm also using Backbone.js on the client side to fetch the API data. If If I create a Collection at
/api/users/:id/movies
then this will work well for GET requests, but POST and PUT requests would seemingly then be directed at:
/api/users/:id/movies/:id
But, seemingly, it would be better if it was posted to
/api/movies/:id
instead. Is that correct? How do people generally deal with RestFul associations?
Not sure what you mean by "POST and PUT requests would seemingly then be directed at...". Does Backbone.js automatically adds parameters to URLs? If so, you should look at configuring it so that it doesn't do that, because it won't be usable with a REST API. Links provided by a REST API should be the full ones, there's nothing to add or remove from them.
Finally, if you want to associate a movie with a user. You would POST the movie (or just its ID) to:
/api/users/:id/movies
It is correct. This is because "movies" are independent from "users". Movies can exist without users, so their relationship are actually "associative".
To create movies, you don't need users at all, so it makes more sense for the POST URI to create movie to be "POST /api/movies".
Alternative of association in RESTful API that I can think of is to have the list of movie IDs in the GET users API response, e.g. a property named "associatedMovieIDs" which has an array of strings of the IDs of the movies associated to the user.
With this, your APIs will then become:
/api/users/
/api/users/:id
/api/movies/
/api/movies/:id

Categories