I want to delete the attachments in JIRA using REST service in JAVA.
restTemplate.delete("http://issusteackingsomething/jira/rest/api/2/attachment/{id})
I need to have the attachment ID from JIRA for the attachment to be deleted.
How do i get that attachment ID?
Use:
https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-getIssue
This is simple URL-requst. Use URL:
http://"Your_domain_jira"/rest/api/2/issue/"Issue ID or Issue Key"
Parse responce json and you find all information about attachments, like that:
"attachment":[{"self":"what ever link", "id":"some sort of id that you need"} ]
You have to know issue key in order to understand to which issue attachment belongs. It can be done in DB or using rest api call:
http://issusteackingsomething/jira/rest/api/latest/issue/ISSUEKEY
In case of REST API call you will have to parse output:
"attachment": [
{
"self":
"id": "1074703",
"filename": "",
"author": {
Related
I'm working on a project in which I'm creating (POST) a book. Once the book is created, a unique bookId is generated and the response looks something like this:
{
"bookId":"123pqr",
"author":"Abc",
"title": "Book1"
}
I have one GET request which basically fetches the book details using bookId - http://localhost:port/{bookId}.
I'm trying to get this above URL whenever I create a book so that my response should look like this:
{
"bookId":"123pqr",
"author":"Abc",
"title": "Book1"
"url": "http://localhost:port/{bookId}"
}
So that if a user clicks on the URL, the user should be navigated to a GET request http://localhost:port/{bookId}. I think I can just hardcode a string "http://localhost:port/" and then append bookId to it and provide the same in response. However, I'm not sure how to set the request type as GET when the URL is clicked. Also, is there a better way to avoid harcoding? Could someone please help? Thanks in advance!
You do not need to specify anything to consider a URL as a GET.
This is natively part of every browser.
However, you could think a bit further and use HATEOAS which specifies the kind of relationship for a specific href
Your response would look like the following where self is standardized to be a GET request since it's the retrieval of the resource
{
"bookId":"123pqr",
"author":"Abc",
"title": "Book1"
"_links": {
"self": {
"href": "http://localhost:port/{bookId}"
}
}
}
More information can be found here
Spring HATEOAS which BTW can also help with building the URI and thus no need to hardcode localhost and port making your app dynamic enough
I am not able to post data to server. On clicking button i submit form and i am getting data into api service class but it's not sending to server which place somewhere else. I am going to give all detail here under:I have other apis method in service class they are working well , but when i want to post data, i am not able to post data and neither getting any response from server while checking database no entry there:
service.ts : orgId is string which is pass in url as foreign key to add adresspostmodel , and data is json object. I am using data:any(reason the actual table has more field which auto generated). when i use postman the api and all working well with same url and json object as i giving hereunder:
service.ts :
public postFormData(orgId: string, data: any): Observable<AdressModel> {
return this.http.post<any>(`${this.ApiUrl}/${orgId}/addresses`, data).pipe(
tap(response => console.log(response)), catchError(this.handleError));
}
onSubmit(){
this.data =
{
"city": "test",
"email": "test#gemiil.com",
"name": "test2",
"recipient": "test",
"street": "test",
"zipCode": "12345"
}
this.ApiService.postFormData(this.organizationId, this.data);
}
this.data actually i am getting data from form, but here form example i am giving you json mock object, which is also correct, here is my json object and whole api in console both api , och json object in console is looking correct for me :
api data in console
{
"city":"test",
"email":"test#gemiil.com",
"name":"test2",
"recipient":"test",
"street":"test",
"zipCode":"12345"
}
Can anyone help to find what's problem is there with logic?
Observable are lazy in nature, so you must subscribe to make it to send request to server.
this.ApiService.postFormData(this.organizationId, this.data).subscribe((resp) => console.log(resp));
https://api.twitter.com/1.1/account_activity/all/prod/webhooks.json?url=https://test.com not working
I have followed all steps to create a new application and getting consumer key, secret keys and also token details and try to create webhook via postman. I am getting follwing error
{
"errors": [
{
"code": 32,
"message": "Could not authenticate you."
}
]
}
I have tried delete and get methods for webhook and it is working fine.
They probably goofed in their example. You just need to move the url parameter from the query string to the form data. Use the x-www-form-urlencoded body.
Also - if you leave the nonce and timestamp blank, then Postman will auto-generate them for you.
enter image description here
The new facebook api allows us to get reactions on a post on a page, for this fb has created a reactions edge
I am able to extract data from this edge by simple hitting post-id/reactions from the graph api explorer.
Here is the graph api request :-
1497117777255241_1526440124323006/reactions
and the response data
{ "data": [
{
"id": "100008182891350",
"name": "Harsh Sharma",
"type": "LOVE"
} ], "paging": {
"cursors": {
"before": "TVRBd01EQTRNVGd5T0RreE16VXdPakUwTmpRd01EQTROalk2TnpnNE5qUTRNRE0zT1RFek16RXkZD",
"after": "TVRBd01EQTRNVGd5T0RreE16VXdPakUwTmpRd01EQTROalk2TnpnNE5qUTRNRE0zT1RFek16RXkZD"
} } }
now i try to do the same using the java rest fb api in which I first extract the post and then using that object I call the get reactions method on it but I dont get any data.
Here is the sample code for the same :-
reactionsCount=post.getReactionsCount();
System.out.println("post id-->"+post.getId()+" reactions--->"+post.getReactionsCount());
reactionsObj=post.getReactions();
for the above post id : there is a reaction on it but I am getting the reaction count as zero via restFB, but I am getting data from graph api.
The reactionObj is also null every time (obtained via reactionsObj=post.getReactions();
)
if(reactionsObj!=null)
{
System.out.println("bring it on reactions-------");
for (ReactionItem reactionListItem : reactionsObj.getData())
{
reactionsMap.put("id", reactionListItem.getId());
reactionsMap.put("name", reactionListItem.getName() );
reactionsMap.put("type",reactionListItem.getType() );
}
}
I am getting posts/comments/likes successfully, only the reactions edge is creating problems.
Please let me know where I am going wrong.
Edit
Connection<Post> postSearch =FacebookClientBean.getFacebookclient().fetchConnection(pageId+"/feed", Post.class);
Collected solutions from the comments:
to get reactions on a Post you have to add the field in the request like this:
fetchConnection(pageId+"/feed", Post.class, Parameter.with("fields","reactions.summary(1)"));
An error message with the content requires version v2.6 or higher is a hint the wrong Graph API version is used to request the node.
Select the correct Version in the DefaultFacebookClient constructor:
new DefaultFacebookClient(accessToken, Version.VERSION_2_6);
Im writing an app for facebook in java.
i have a class named FacebookClient that i got from facebook.
withe this class i can connect to facebook by using
FacebookClient client = new FacebookClient();
client.login(request, response, "api_key", "sec_key");
and get user info with
client.users_getinfo
(For example: client.users_getinfo(String.class, uidJSON, "first_name , last_name , sex , pic_big , pic_small ", "format=json");
the problem is that i need the user profile url and i can't get it!!
does anyone know how to get it (the function or the Query )
Thanks
Check out the Facebook Graph API here
If you make an API call me it will return a large JSON containing various information about you, (or a specified user), and one of the entries is 'link'
Here is a sample call.
https://graph.facebook.com/me?access_token=<the access token>
and the sample return will look like:
{
"id": "01234567",
"name": "Kenny Cason",
"first_name": "Kenny",
"last_name": "Cason",
"link": "http://www.facebook.com/kenny.cason",
"about": "life only comes once",
"birthday": "00/11/2222",
"location": {
"id": "110184922344060",
"name": "Washington, District of Columbia"
},
...
a bunch more info
...
}
You can see the link entry which is a link to my facebook profile. let me know if you need more information.