Here I have a response from the facebook server that returns the list of albums of a selected user. I want to create an array for all the album names labeled "name" as well as the "link" and "cover_photo" to be ready to processed into a listview
{
"data": [
{
"id": "664462156031",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"name": "Mobile Uploads",
"link": "https://www.facebook.com/album.php?fbid=664462156031&id=68004222&aid=2081375",
"cover_photo": "754991180141",
"count": 88,
"type": "mobile",
"created_time": "2012-05-12T00:38:14+0000",
"updated_time": "2013-11-04T20:45:08+0000",
"can_upload": false
},
{
"id": "813288706431",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"name": "Bitstrips Photos",
"link": "https://www.facebook.com/album.php?fbid=813288706431&id=68004222&aid=1073741826",
"cover_photo": "813288781281",
"count": 1,
"type": "app",
"created_time": "2013-10-31T21:53:11+0000",
"updated_time": "2013-10-31T21:53:15+0000",
"can_upload": false
},
{
"id": "757384214481",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"name": "Galveston Vacation 2013",
"description": "Our trip before joining Air Force",
"link": "https://www.facebook.com/album.php?fbid=757384214481&id=68004222&aid=1073741825",
"cover_photo": "757221350861",
"count": 8,
"type": "normal",
"created_time": "2013-05-15T18:37:19+0000",
"updated_time": "2013-05-15T22:12:52+0000",
"can_upload": false,
"likes": {
"data": [
{
"id": "100002572634186",
"name": "Misty O'Quain"
},
{
"id": "100000582072776",
"name": "Clifford Joyce"
},
{
"id": "1045514613",
"name": "Caity Ellender"
}
],
"paging": {
"cursors": {
"after": "MTA0NTUxNDYxMw==",
"before": "MTAwMDAyNTcyNjM0MTg2"
}
}
}
},
{
"id": "542202136091",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"name": "Profile Pictures",
"link": "https://www.facebook.com/album.php?fbid=542202136091&id=68004222&aid=2054735",
"cover_photo": "749743202131",
"count": 20,
"type": "profile",
"created_time": "2010-09-02T04:43:32+0000",
"updated_time": "2013-04-13T13:46:14+0000",
"can_upload": false
},
{
"id": "646032913381",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"name": "Cover Photos",
"link": "https://www.facebook.com/album.php?fbid=646032913381&id=68004222&aid=2079483",
"cover_photo": "681058471881",
"count": 2,
"type": "cover",
"created_time": "2012-03-22T00:25:50+0000",
"updated_time": "2012-07-17T15:26:24+0000",
"can_upload": false
},
{
"id": "599115930391",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"name": "Timeline Photos",
"link": "https://www.facebook.com/album.php?fbid=599115930391&id=68004222&aid=2073818",
"cover_photo": "599115935381",
"count": 1,
"type": "wall",
"created_time": "2011-10-20T14:25:23+0000",
"updated_time": "2011-10-20T14:25:23+0000",
"can_upload": false
},
{
"id": "551798524851",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"name": "My Year - 2010",
"link": "https://www.facebook.com/album.php?fbid=551798524851&id=68004222&aid=2060899",
"cover_photo": "551798544811",
"count": 1,
"type": "normal",
"created_time": "2010-12-19T05:11:51+0000",
"updated_time": "2010-12-19T05:12:14+0000",
"can_upload": false
},
{
"id": "522841060841",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"name": "Night Lightnin",
"description": "Always wanted to do this, because lightning is way cooler at night. Perhaps next time I'll be able to refine my methods a little. Read as \"bring tripod so you don't have to prop cam up on roof of car\"",
"location": "Just north of Sulphur",
"link": "https://www.facebook.com/album.php?fbid=522841060841&id=68004222&aid=2036447",
"cover_photo": "522841195571",
"count": 15,
"type": "normal",
"created_time": "2009-09-16T04:38:43+0000",
"updated_time": "2009-09-16T04:42:32+0000",
"can_upload": false
},
{
"id": "513270939441",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"name": "The Stuff That Doesn't Make Another Album",
"description": "See title.",
"location": "Good question",
"link": "https://www.facebook.com/album.php?fbid=513270939441&id=68004222&aid=2029083",
"cover_photo": "513271029261",
"count": 9,
"type": "normal",
"created_time": "2009-03-03T06:43:09+0000",
"updated_time": "2009-04-01T02:20:22+0000",
"can_upload": false,
"comments": {
"data": [
{
"id": "513270939441_3444",
"from": {
"name": "Misty Bylsma Royal",
"id": "592607110"
},
"message": "I love how the beautiful lady pile is in the same album as the bull pics. Nice.",
"can_remove": false,
"created_time": "2009-03-03T22:37:18+0000",
"like_count": 0,
"user_likes": false
},
{
"id": "513270939441_3451",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"message": "Only because they are both things that i only had a few pictures of.",
"can_remove": false,
"created_time": "2009-03-04T02:46:11+0000",
"like_count": 0,
"user_likes": false
}
],
"paging": {
"cursors": {
"after": "Mg==",
"before": "MQ=="
}
}
}
},
{
"id": "511605661671",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"name": "What the...?",
"description": "What's wrong with the rain? It's flaky and piles up on stuff... Did the plants leak something?\n",
"location": "Outside",
"link": "https://www.facebook.com/album.php?fbid=511605661671&id=68004222&aid=2026641",
"cover_photo": "511605681631",
"count": 54,
"type": "normal",
"created_time": "2008-12-11T11:59:27+0000",
"updated_time": "2008-12-13T18:06:00+0000",
"can_upload": false
},
{
"id": "511565886381",
"from": {
"name": "Nate Ellender",
"id": "68004222"
},
"name": "The Christmas Tree Farm",
"description": "An Ellender Tradition",
"location": "Grant",
"link": "https://www.facebook.com/album.php?fbid=511565886381&id=68004222&aid=2026590",
"cover_photo": "511566170811",
"count": 19,
"type": "normal",
"created_time": "2008-12-09T02:38:54+0000",
"updated_time": "2008-12-09T02:55:21+0000",
"can_upload": false
}
],
"paging": {
"cursors": {
"after": "NTExNTY1ODg2Mzgx",
"before": "NjY0NDYyMTU2MDMx"
}
}
}
Also, here is where the json data is returned (response). I will need to start parsing the data under response.
Session.NewPermissionsRequest np = new Session.NewPermissionsRequest(this, "friends_photos");
Session.getActiveSession().requestNewReadPermissions(np);
Request rq = new Request(Session.getActiveSession(), userID + "/albums", null, HttpMethod.GET, new Request.Callback() {
#Override
public void onCompleted(Response response) {
}
});
rq.executeAsync();
Any example would be helpful. I would like to study the code to get a better understanding on parsing json data.
You can get a good example of how to do here: http://www.androidhive.info/2012/01/android-json-parsing-tutorial/
Basically you have to use JSONObject and JSONArray, that you can get from getJSONObject() and getJSONArray().
Once you're on the good spot, use getJSONString() to get the desired value.
In your case it will be something like this:
JSONObject json = new JSONObject(response)
JSONArray jarray = json.getJSONArray("data");
for(int i = 0; i < jarray.length(); i++){
JSONObject oneAlbum = jarray.getJSONObject(i);
//get your values
oneAlbum.getJSONString("name"); // this will return you the album's name.
}
Hope this will help you.
Try this
Session.NewPermissionsRequest np = new Session.NewPermissionsRequest(this, "friends_photos");
Session.getActiveSession().requestNewReadPermissions(np);
Request rq = new Request(Session.getActiveSession(), userID + "/albums", null, HttpMethod.GET, new Request.Callback() {
#Override
public void onCompleted(Response response) {
JSONArray albumArr = response.getGraphObject().getInnerJSONObject().getJSONArray("data");
for (int i = 0; i < albumArr.length(); i++) {
JSONObject item = albumArr.getJSONObject(i);
System.out.println("id : " + item.getString("id"));
System.out.println("fromName : " + item.getJSONObject("from").getString("name"));
System.out.println("fromid : " + item.getJSONObject("from").getString("id"));
System.out.println("link : " + item.getString("link"));
System.out.println("cover_photo : " + item.getString("cover_photo"));
System.out.println("count : " + item.getString("count"));
System.out.println("created_time : " + item.getString("created_time"));
System.out.println("updated_time : " + item.getString("updated_time"));
System.out.println("can_upload : " + item.getString("can_upload"));
}
}
});
rq.executeAsync();
Related
I'm trying to read date from JSON using a URL , but it throws an exception. and the response from header is 301 Moved Permanently
this basically means the there is something wrong with link, but I cannot figure out what it is exactly since the API provider did not mention anything in regard to changes to their API
Any help is appreciated.
here is my code
private static String readUrl(String urlString) throws Exception {
BufferedReader reader = null;
try {
URL url = new URL(urlString);
reader = new BufferedReader(new InputStreamReader(url.openStream()));
StringBuffer buffer = new StringBuffer();
int read;
char[] chars = new char[1024];
while ((read = reader.read(chars)) != -1)
buffer.append(chars, 0, read);
return buffer.toString();
} finally {
if (reader != null)
reader.close();
}
}
String url = "http://webservice.fanart.tv/v3/movies/" + movie.id + "?api_key=" + apikey;
List<String> enClearLogos = new ArrayList<>();
try {
JSONObject json = new JSONObject(readUrl(url));
JSONArray jsonArray = json.getJSONArray("hdmovielogo");
for(int i = 0; i < jsonArray.length(); i++){
JSONObject movieObject = jsonArray.getJSONObject(i);
if (movieObject.getString("lang").equalsIgnoreCase("en"))
enClearLogos.add(movieObject.getString("url"));
}
} catch (Exception e) {
e.printStackTrace();
}
here example
{
"name": "The Bad Guys",
"tmdb_id": "629542",
"imdb_id": "tt8115900",
"hdmovieclearart": [
{
"id": "362695",
"url": "https://assets.fanart.tv/fanart/movies/629542/hdmovieclearart/the-bad-guys-6231fd4379a87.png",
"lang": "en",
"likes": "6"
},
{
"id": "362696",
"url": "https://assets.fanart.tv/fanart/movies/629542/hdmovieclearart/the-bad-guys-6231fd53d3a96.png",
"lang": "ru",
"likes": "3"
},
{
"id": "367992",
"url": "https://assets.fanart.tv/fanart/movies/629542/hdmovieclearart/the-bad-guys-6280fb431126b.png",
"lang": "cz",
"likes": "2"
}
],
"hdmovielogo": [
{
"id": "369396",
"url": "https://assets.fanart.tv/fanart/movies/629542/hdmovielogo/the-bad-guys-629dc8e4da93a.png",
"lang": "fr",
"likes": "3"
},
{
"id": "368375",
"url": "https://assets.fanart.tv/fanart/movies/629542/hdmovielogo/the-bad-guys-62899cfba2c00.png",
"lang": "en",
"likes": "3"
},
{
"id": "371110",
"url": "https://assets.fanart.tv/fanart/movies/629542/hdmovielogo/the-bad-guys-62bdec1d38353.png",
"lang": "es",
"likes": "2"
},
{
"id": "355025",
"url": "https://assets.fanart.tv/fanart/movies/629542/hdmovielogo/the-bad-guys-61ba168a41d9b.png",
"lang": "ru",
"likes": "2"
},
{
"id": "355031",
"url": "https://assets.fanart.tv/fanart/movies/629542/hdmovielogo/the-bad-guys-61ba1f851cd32.png",
"lang": "en",
"likes": "2"
},
{
"id": "355032",
"url": "https://assets.fanart.tv/fanart/movies/629542/hdmovielogo/the-bad-guys-61ba1f96a497e.png",
"lang": "en",
"likes": "1"
},
{
"id": "366828",
"url": "https://assets.fanart.tv/fanart/movies/629542/hdmovielogo/the-bad-guys-626984d807f4d.png",
"lang": "cz",
"likes": "1"
},
{
"id": "360922",
"url": "https://assets.fanart.tv/fanart/movies/629542/hdmovielogo/the-bad-guys-6217a7c5ba60d.png",
"lang": "it",
"likes": "0"
}
],
"movieposter": [
{
"id": "367357",
"url": "https://assets.fanart.tv/fanart/movies/629542/movieposter/the-bad-guys-6274ea20dcc86.jpg",
"lang": "en",
"likes": "2"
},
{
"id": "371114",
"url": "https://assets.fanart.tv/fanart/movies/629542/movieposter/the-bad-guys-62bdecfbd6715.jpg",
"lang": "es",
"likes": "2"
},
{
"id": "368000",
"url": "https://assets.fanart.tv/fanart/movies/629542/movieposter/the-bad-guys-628108a944560.jpg",
"lang": "pt",
"likes": "2"
},
{
"id": "367358",
"url": "https://assets.fanart.tv/fanart/movies/629542/movieposter/the-bad-guys-6274ea33e2ed5.jpg",
"lang": "00",
"likes": "2"
},
{
"id": "355026",
"url": "https://assets.fanart.tv/fanart/movies/629542/movieposter/the-bad-guys-61ba169a2b57e.jpg",
"lang": "en",
"likes": "2"
},
{
"id": "358210",
"url": "https://assets.fanart.tv/fanart/movies/629542/movieposter/the-bad-guys-61ee6f9a14706.jpg",
"lang": "00",
"likes": "1"
},
{
"id": "367991",
"url": "https://assets.fanart.tv/fanart/movies/629542/movieposter/the-bad-guys-6280fb200c5bf.jpg",
"lang": "cz",
"likes": "0"
},
{
"id": "367990",
"url": "https://assets.fanart.tv/fanart/movies/629542/movieposter/the-bad-guys-6280fb1ba6d39.jpg",
"lang": "cz",
"likes": "0"
}
],
"moviethumb": [
{
"id": "371117",
"url": "https://assets.fanart.tv/fanart/movies/629542/moviethumb/the-bad-guys-62bdee5332ad2.jpg",
"lang": "es",
"likes": "2"
},
{
"id": "367994",
"url": "https://assets.fanart.tv/fanart/movies/629542/moviethumb/the-bad-guys-6280fb7b224fd.jpg",
"lang": "cz",
"likes": "1"
},
{
"id": "370972",
"url": "https://assets.fanart.tv/fanart/movies/629542/moviethumb/the-bad-guys-62bbbc9385121.jpg",
"lang": "en",
"likes": "0"
},
{
"id": "367260",
"url": "https://assets.fanart.tv/fanart/movies/629542/moviethumb/the-bad-guys-6272bfb851ca5.jpg",
"lang": "en",
"likes": "0"
}
],
"moviebackground": [
{
"id": "355027",
"url": "https://assets.fanart.tv/fanart/movies/629542/moviebackground/the-bad-guys-61ba16ab7df92.jpg",
"lang": "",
"likes": "2"
},
{
"id": "367177",
"url": "https://assets.fanart.tv/fanart/movies/629542/moviebackground/the-bad-guys-6271f6e99b835.jpg",
"lang": "",
"likes": "0"
}
],
"moviedisc": [
{
"id": "367993",
"url": "https://assets.fanart.tv/fanart/movies/629542/moviedisc/the-bad-guys-6280fb602b271.png",
"lang": "cz",
"likes": "1",
"disc": "1",
"disc_type": "bluray"
},
{
"id": "358213",
"url": "https://assets.fanart.tv/fanart/movies/629542/moviedisc/the-bad-guys-61ee85436574f.png",
"lang": "en",
"likes": "0",
"disc": "1",
"disc_type": "bluray"
}
],
"moviebanner": [
{
"id": "358216",
"url": "https://assets.fanart.tv/fanart/movies/629542/moviebanner/the-bad-guys-61ee93348cb62.jpg",
"lang": "en",
"likes": "1"
},
{
"id": "370973",
"url": "https://assets.fanart.tv/fanart/movies/629542/moviebanner/the-bad-guys-62bbbd7215d83.jpg",
"lang": "en",
"likes": "0"
}
]
}
exception message
W/System.err: org.json.JSONException: Value <html> of type java.lang.String cannot be converted to JSONObject
W/System.err: at org.json.JSON.typeMismatch(JSON.java:112)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:168)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:181)
The http:// causes url redirection and throws this message in the header response (301 Moved Permanently) so I had to use https:// instead now everything works nicely.
more info here Response 301 Moved Permanently
Attached the JSON of adaptive card I sent in teams.
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Publish Adaptive Card schema",
"weight": "bolder",
"size": "medium"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "Image",
"url": "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
"size": "medium",
"style": "person"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Matt Hidinger",
"weight": "bolder",
"wrap": true
},
{
"type": "TextBlock",
"spacing": "none",
"text": "Created Tuesday, Feb 14, 2017",
"isSubtle": true,
"wrap": true
}
]
}
]
}
]
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Now that we have defined the main rules and features of the format, we need to produce a schema and publish it to GitHub. The schema will be the starting point of our reference documentation.",
"wrap": true
},
{
"type": "FactSet",
"facts": [
{
"title": "Board:",
"value": "Adaptive Card"
},
{
"title": "List:",
"value": "Backlog"
},
{
"title": "Assigned to:",
"value": "Matt Hidinger"
},
{
"title": "Due date:",
"value": "Not set"
}
]
}
]
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Set due date",
"card": {
"version": "1.0",
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Date",
"id": "dueDate",
"title": "Select due date"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK"
}
]
}
},
{
"type": "Action.ShowCard",
"title": "Comment",
"card": {
"version": "1.0",
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Text",
"id": "comment",
"isMultiline": true,
"placeholder": "Enter your comment"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK"
}
]
}
},
{
"type": "Action.OpenUrl",
"title": "View",
"url": "http://adaptivecards.io"
}
]
}
After User entered values and click ok, reply from bot is "Echo:"
How can i display the entered value as reply from bot.
I have implemented this to get activity, but this method is not called when use click ok.
I'm using the new Paypal Sync Api to get all transactions in a period of time. I need to be able to refund them too.
As all our transactions are always sales I need the sale ID to refund a transaction as stated in https://developer.paypal.com/docs/integration/direct/payments/refund-payments/#set-up-your-development-environment
Unfortunately I can not find anything in the transactions response which can be used as a sale ID
{
"transaction_details": [
{
"transaction_info": {
"paypal_account_id": "6EN7PS8P9DV6J",
"transaction_id": "05P62542TL3758730",
"transaction_event_code": "T0006",
"transaction_initiation_date": "2019-07-04T12:49:55+0000",
"transaction_updated_date": "2019-07-04T12:53:09+0000",
"transaction_amount": {
"currency_code": "USD",
"value": "10.00"
},
"fee_amount": {
"currency_code": "USD",
"value": "-0.49"
},
"transaction_status": "S",
"ending_balance": {
"currency_code": "USD",
"value": "0.00"
},
"available_balance": {
"currency_code": "USD",
"value": "0.00"
},
"protection_eligibility": "01"
},
"payer_info": {
"account_id": "6EN7PS8P9DV6J",
"email_address": "paypaltester3#test.de",
"address_status": "Y",
"payer_status": "Y",
"payer_name": {
"given_name": "Tester Three",
"surname": "Tester Three",
"alternate_full_name": "Tester Three Tester Three"
},
"country_code": "DE"
},
"shipping_info": {
"name": "Tester Three, Tester Three",
"address": {
"line1": "Teststreet. 1",
"city": "SomeCity",
"country_code": "DE",
"postal_code": "23434"
}
},
"cart_info": {
"item_details": [
{
"item_quantity": "1",
"item_unit_price": {
"currency_code": "USD",
"value": "10.00"
},
"item_amount": {
"currency_code": "USD",
"value": "10.00"
},
"total_item_amount": {
"currency_code": "USD",
"value": "10.00"
}
}
]
},
"store_info": {},
"auction_info": {},
"incentive_info": {}
}
],
"account_number": "96B45RCG6AX3E",
"start_date": "2019-07-03T00:00:00+0000",
"end_date": "2019-07-04T16:00:00+0000",
"last_refreshed_datetime": "2019-07-15T08:59:59+0000",
"page": 1,
"total_items": 15,
"total_pages": 1,
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/reporting/transactions?start_date=2019-07-03T00%3A00%3A00Z&end_date=2019-07-04T16%3A00%3A00Z&fields=all&page_size=500&page=1",
"rel": "self",
"method": "GET"
}
]
}
I tested a refund call with a transactionId and with an invoiceId but both returned "INTERNAL_SERVICE_ERROR".
Is there any way to get the sale ID by an API after the customer has completed the payment or do I have to save the sale ID in a database after creating a payment?
Thanks
With T0006 you are lucky, it is a simple PayPal Checkout APIs. transaction, it would be harder with T0002. Anyway, no the response have much more data. The example is below.
You can find it in invoice_number, or invoice_id. If only you had this data during payment creation procedures.
"transaction_details":[
{
"transaction_info":{
"paypal_account_id":"HHHHH",
"transaction_id":"040404040404040",
"transaction_event_code":"T0006",
"transaction_initiation_date":"2019-10-31T06:21:37+0000",
"transaction_updated_date":"2019-10-31T06:31:02+0000",
"transaction_amount":{
"currency_code":"AUD",
"value":"96.90"
},
"fee_amount":{
"currency_code":"AUD",
"value":"-4.08"
},
"shipping_amount":{
"currency_code":"AUD",
"value":"17.90"
},
"transaction_status":"S",
"transaction_subject":"Full License",
"ending_balance":{
"currency_code":"AUD",
"value":"92.82"
},
"available_balance":{
"currency_code":"AUD",
"value":"92.82"
},
"invoice_id":"1110-US1",
"protection_eligibility":"01"
},
"payer_info":{
"account_id":"HHHHH",
"email_address":"test#paypal.com",
"address_status":"Y",
"payer_status":"Y",
"payer_name":{
"given_name":"First",
"surname":"Last",
"alternate_full_name":"First Last"
},
"country_code":"GB"
},
"shipping_info":{
"name":"Shaun Smith",
"address":{
"line1":"123, Some Road",
"line2":"Shop 4",
"city":"Melbourne",
"country_code":"AU",
"postal_code":"3185"
}
},
"cart_info":{
"item_details":[
{
"item_name":"Full License",
"item_description":"Full License",
"item_quantity":"1",
"item_unit_price":{
"currency_code":"AUD",
"value":"79.00"
},
"item_amount":{
"currency_code":"AUD",
"value":"79.00"
},
"total_item_amount":{
"currency_code":"AUD",
"value":"79.00"
},
"invoice_number":"1110-US1"
}
]
},
"store_info":{
},
"auction_info":{
},
"incentive_info":{
}
},
I am trying to implement REST API for Fortify Software Security Center using Java. I am able to obtain
1)token by using following url
http://xxx.xxx.xxx.xxx:8080/ssc/api/v1/auth/obtain_token
response for above URL as below
{
"data": {
"token": "NDIxMjE0NjUtOGIwNy00ZjFiLWEzMTUtZjZkYTg0MWY1Zjgz",
"creationDate": "2016-09-14T05:49:34.000+0000",
"terminalDate": "2016-09-15T05:49:34.000+0000"
},
"responseCode": 200
}
and
2)get list of reports using following URL
http://xxx.xxx.xxx.xxx:8080/ssc/api/v1/reports
response for above URL as below
{
"data": [
{
"note": "",
"_href": "http://xxx.xxx.xxx.xxx:8080/ssc/api/v1/reports/17",
"formatDefaultText": "PDF",
"projects": [
{
"id": 16,
"name": "Project 1",
"versions": [
{
"id": 30,
"name": "1.0",
"developmentPhase": "New"
}
]
}
],
"authEntity": {
"id": 2,
"userName": "AAA",
"firstName": "AAA",
"lastName": "AAA"
},
"isPublished": false,
"format": "PDF",
"generationDate": "2016-08-03T10:56:46.000+0000",
"statusDefaultText": "Processing Complete",
"reportDefinitionId": null,
"type": "ISSUE",
"typeDefaultText": "Issue Reports",
"inputReportParameters": null,
"name": "Project 1",
"id": 17,
"status": "PROCESS_COMPLETE"
},
{
"note": "",
"_href": "http://xxx.xxx.xxx.xxx:8080/ssc/api/v1/reports/22",
"formatDefaultText": "PDF",
"projects": [
{
"id": 16,
"name": "Project 2",
"versions": [
{
"id": 30,
"name": "1.0",
"developmentPhase": "New"
}
]
}
],
"authEntity": {
"id": 10,
"userName": "BBB",
"firstName": "BBB",
"lastName": "BBB"
},
"isPublished": false,
"format": "PDF",
"generationDate": "2016-08-24T13:45:30.000+0000",
"statusDefaultText": "Processing Complete",
"reportDefinitionId": null,
"type": "ISSUE",
"typeDefaultText": "Issue Reports",
"inputReportParameters": null,
"name": "Project 2",
"id": 22,
"status": "PROCESS_COMPLETE"
},
{
"note": "",
"_href": "http://xxx.xxx.xxx.xxx:8080/ssc/api/v1/reports/41",
"formatDefaultText": "PDF",
"projects": [
{
"id": 2,
"name": "Project 3",
"versions": [
{
"id": 3,
"name": "1.0",
"developmentPhase": "Active Development"
}
]
}
],
"authEntity": {
"id": 10,
"userName": "CCC",
"firstName": "CCC",
"lastName": "CCC"
},
"isPublished": false,
"format": "PDF",
"generationDate": "2016-08-25T16:56:22.000+0000",
"statusDefaultText": "Processing Complete",
"reportDefinitionId": null,
"type": "ISSUE",
"typeDefaultText": "Issue Reports",
"inputReportParameters": null,
"name": "Project 3",
"id": 41,
"status": "PROCESS_COMPLETE"
},
{
"note": "",
"_href": "http://xxx.xxx.xxx.xxx:8080/ssc/api/v1/reports/57",
"formatDefaultText": "XLS",
"projects": [
{
"id": 2,
"name": "Project 4",
"versions": [
{
"id": 3,
"name": "1.0",
"developmentPhase": "Active Development"
}
]
}
],
"authEntity": {
"id": 11,
"userName": "DDD",
"firstName": "DDD",
"lastName": "DDD"
},
"isPublished": false,
"format": "XLS",
"generationDate": "2016-09-09T15:46:22.000+0000",
"statusDefaultText": "Processing Complete",
"reportDefinitionId": null,
"type": "ISSUE",
"typeDefaultText": "Issue Reports",
"inputReportParameters": null,
"name": "Project 4",
"id": 57,
"status": "PROCESS_COMPLETE"
}
],
"count": 4,
"responseCode": 200,
"links": {
"last": {
"href": "http://xxx.xxx.xxx.xxx:8080/ssc/api/v1/reports/?start=0"
},
"first": {
"href": "http://xxx.xxx.xxx.xxx:8080/ssc/api/v1/reports/?start=0"
}
}
}
But I didn't find any end point URL to download the saved reports. Can you please help me to get the end point URL or provide reference API document for HP fortify Software Security Center.
I know this is kind of an old post but just ran into the issue myself and found the solution.
First you have to request a file token as a HTTPPost:
http://xxx.xxx.xxx.xxx:8080/ssc/api/v1/fileTokens
with:
{"fileTokenType": "REPORT_FILE"}
in the request body.
This will return a unique id that you will use to fetch your report.
Next you will make another get request like such:
http://xxx.xxx.xxx.xxx:8080/ssc/transfer/reportDownload.html?mat=[file_token]&id=[project_id]
you will replace the [file_token] with the token returned from the above post and [project_id] with the project you want to download the report for.
so for example:
http://xxx.xxx.xxx.xxx:8080/ssc/transfer/reportDownload.html?mat=7e8d912e-2432-6496-3232-709b05513bf2&id=1
This will return the binary data that you can then save to a file. The file type is specified in the report data as "format"
I did some set of activities on json script. Need to add precondition on it.
how to use precondition on json script.
In precondition, i need to check the mysql db field. once flag as 'Y',
start execution else should be stop the execution.
You can use a ShellCommandPrecondition for this which will let you write a custom precondition.
{
"objects": [
{
"schedule": {
"ref": "DefaultSchedule"
},
"resourceRole": "DataPipelineDefaultResourceRole",
"role": "DataPipelineDefaultRole",
"name": "DefaultResource1",
"id": "ResourceId_dWoZ0",
"type": "Ec2Resource",
"terminateAfter": "1 Hour"
},
{
"name": "DefaultPrecondition1",
"id": "PreconditionId_yA2rV",
"type": "ShellCommandPrecondition",
"command": "<Script to check mysql field>"
},
{
"occurrences": "1",
"period": "1 Day",
"name": "RunOnce",
"id": "DefaultSchedule",
"type": "Schedule",
"startAt": "FIRST_ACTIVATION_DATE_TIME"
},
{
"failureAndRerunMode": "CASCADE",
"schedule": {
"ref": "DefaultSchedule"
},
"resourceRole": "DataPipelineDefaultResourceRole",
"role": "DataPipelineDefaultRole",
"pipelineLogUri": "s3://<mybucket>",
"scheduleType": "cron",
"name": "Default",
"id": "Default"
},
{
"schedule": {
"ref": "DefaultSchedule"
},
"name": "DefaultActivity1",
"runsOn": {
"ref": "ResourceId_dWoZ0"
},
"precondition": {
"ref": "PreconditionId_yA2rV"
},
"id": "ActivityId_gmQ0W",
"type": "ShellCommandActivity",
"command": "echo 'Hello world'"
}
],
"parameters": []
}