I have ObjectID of defect.
Defect should be updated using only web services.
Get a security token using this endpoint:
https://rally1.rallydev.com/slm/webservice/v2.0/security/authorize
The result includes the token, "fbaa0c04-2616-....
{"OperationResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": [], "Warnings": [], "SecurityToken": "fbaa0c04-2616-...."}}
Post using 'create' endpoint with the security token appended in the end. In this example 123456789 is the OID of the defect where Description field is being updated
URL:
https://rally1.rallydev.com/slm/webservice/v2.0/defect/123456789?key=fbaa0c04-...
Request Body:
{
"Defect":{
"Description":"some description"
}
}
Here is another example of a Request Body (payload) where two fields are updated, one of which is the Owner, which is a reference to a User object. Reference fields must use ObjectID:
{"Defect":{
"State":"Open",
"Owner":"/user/987654321"
}
}
You'll find the Rally Rest Toolkit for Java helpful.
The following example shows a full CRUD lifecycle:
https://github.com/RallyTools/RallyRestToolkitForJava/blob/master/src/main/resources/examples/com/rallydev/rest/CrudExample.java
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
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
Environment: Cloud Foundry Trail
I deployed my business & approuter applications using help
Now my requirement is get below user profile after XSUAA login.
Is there any API to get user profile details?
{
"lastName": "XXXXX",
"passwordStatus": "enabled",
"mail": "XXXXX#gmail.com",
"displayName": "XXXX XXXX XXXXX",
"uid": "XXXXXX",
"photoUrl": "https://www.gravatar.com/avatar/760fcd379cf60090e1e27b052f9e49bd?d=mm",
"firstName": "XXXX",
"contactPreferenceEmail": "unknown",
"status": "active",
"spUsersAttributes": [
{
"ServiceProviderName": "sapcpcf",
"NameID": "XXXXX",
"Status": "ACTIVE",
"ActivationTime": "20181026050006Z"
}
]
}
Updated answer:
The IdP used by default on Cloud Foundry does not use SAML. Thus, mapping of SAML attributes does not work. Use the approach listed below only when using an IdP that supports SAML.
Instead, when using the default IdP, there three fields (given_name, family_name, email), that can be accessed as follows:
AuthTokenAccessor.getCurrentToken().get().getJwt().getClaim("email").asString();
Original answer:
you can do the following:
First, add a role template to your xs-security.json you used to configure your XSUAA instance like this:
{
"name": "Authenticated",
"description": "All authenticated users",
"attribute-references": [
"given_name",
"family_name",
"email"
]
}
Note that you need to recreate the XSUAA instance with the new config in order for this change to work.
Now, in the roles section of your Identity Provider (if you use the default Cloud Foundry IdP you can find that under the "Security" tab on the left of the Cloud Cockpit), you can configure how these fields should be filled. Choose "Identity Provider" there.
Of course make sure that this role is assigned to every user.
Finally, you read the information using the UserAccessor:
final User currentUser = UserAccessor.getCurrentUser();
currentUser.getAttribute("email");
This should help you get the necessary information!
Currently, there is no dedicated API to get all of these user profile details. You can use the AuthTokenAccessor to access the current JWT which should contain this information.
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": {
I'm using Spring MVC and Spring HateOAS to make a restful and stateless JSON API.
Everything works fine. But i have a "conception" question. My API use an authentication token in every request. For example, you use the login API to get your authentication token, and when you call my API you must use it like this :
http://some_host/api/foo/bar?token=abcd
The API always respond a JSON and links are generated via Spring HateOAS. For exemple :
{
"label" : "foo",
"links" : [
"rel" : "self",
"href" : "http://some_host/api/foo/bar/1234656"
]
}
The question is : Should i add the authentication token in the generated URL ? (so it will be http://some_host/api/foo/bar/1234656?token=abcd)
I can't find any advice or convention for that.
Usually, authentication tokens are communicated via standard HTTP headers (such as the Authorization header in the case of HTTP Basic or Digest). The other common one is via a cookie. In Servlet environments, this is usually the JSESSIONID cookie.
Generally speaking, you shouldn't see authentication tokens passed as part of the request URL.
This is an old question, but the answer is definitely no.
http://some_host/api/foo/bar/1234656 is supposed to be the uniform identifier (URI) and location (URL) for that resource. It's the one URL you can rely on. You can always get the resource using that URL but you'll never get the resource with http://some_host/api/foo/bar?token=abcd again, because the token will expire.
Calling the URL with the token appended is one thing, but it should never appear in the link, because it has nothing to do with the resource. It's the client's responsibility to send the token, not the server's one.