Ebay Daily Deals API - json

I am trying to implement ebay's daily deals api.
[http://deals.ebay.com/feeds/json]
into my angular web application. The only problem is when I go to this url the json comes back is this:
({ebaydailydeals:{"items": [
{
"endtime": "1433170740000",
"convertedcurrentprice": "329.99",
"smallpictureurl": "http://i.ebayimg.com/00/s/NTAwWDUwMA==/z/1kMAAOSwBLlVZc9d/$_1.JPG",
"location": "Elizabeth, NJ",
"pricedisplay": "MSRP",
"itemid": "331566158178",
"savingsrate": "40%",
"title": "Acer Aspire E5 15.6\" Notebook - I5-4210U, 4GB Ram, 500GB HDD, Windows 8.1",
"msrp": "549.99",
"autopay": true,
"description": "N/A",
"primarycategoryid": "177",
"quantity": 722,
"picture175url": "http://i.ebayimg.com/00/s/NTAwWDUwMA==/z/1kMAAOSwBLlVZc9d/$_1.JPG",
"dealurl": "http://deals.ebay.com/5002063567",
"pictureurl": "http://i.ebayimg.com/00/s/NTAwWDUwMA==/z/1kMAAOSwBLlVZc9d/$_1.JPG",
"primarycategoryname": "Computers/Tablets & Networking:Laptops & Netbooks:PC Laptops & Netbooks",
"quantitysold": 88
},
If I copy the json into a formatter its saying the json is not valid. Before I spend any more time bulldogging this thing I am looking for some validation that this is doable or not.

It seems like you need to make a request to the following URL:
http://api.epn.ebay.com/deals/v1/country/us/feed/json?feedType=json
You can customize this as you please, here's some helpful documentation:
http://www.helios825.org/eDD.php

Related

Microsoft Teams cards as html

I have Microsoft Teams chat messages collected via API and want to display those on a website. The problem comes when JSONs of cards are in these chat messages. I tried displaying adaptive cards with Adaptive Card JS SDK and it displayed adaptive card type fine. But I can't find any reference to how can I display other card types correctly.
Few thoughts:
Can I convert any other card type to an Adaptive Card JSON (either
by a library or coding the con so I can display with Adaptive Card
JS SDK? But then if I do it by code myself will I able to handle all
card types/scenarios?
Is there any JS library that could show JSONs of cards other than
Adaptive cards also
I need to be able to display any card type, but it doesn't need to be an exact match of how displayed in the MS Teams app (closer the better :) ). I don't need any functionalities in cards as button clicks/redirections, just card need to be rendered in HTML as it would in MS Teams.
Note: I have the content types of card JSON as application/vnd.microsoft.card.hero, application/vnd.microsoft.card.thumbnail, application/vnd.microsoft.teams.card.o365connector, etc from chat meta data.
eg 1: Card from Wikipedia app
JSON for the card
{
"title": "Unidentified flying object",
"text": "unidentified flying object (<span>UFO</span>) is any aerial phenomenon that cannot immediately be identified or explained. Most <span>UFOs</span> are identified or investigated",
"images": [
{
"alt": "Unidentified flying object",
"url": "https://upload.wikimedia.org/wikipedia/commons/b/bc/PurportedUFO2cropped.jpg"
}
],
"buttons": [
]
}
eg 2: Card of Stocks app
JSON for the card
{
"sections": [
{
"activityTitle": "<span style=\"font-weight:600;font-size:1.8rem\">Apple Inc (Nasdaq Stock Market: AAPL)</span>",
"activitySubtitle": "<span style=\"font-size:1.6rem\">125.89 <span style=\"color:#7FBA00\">▲ 2.35 (1.90%)</span></span>",
"activityText": "\r\n<br/>\r\n<div style=\"font-size:1.2rem\">\r\n <p>\r\n <span style=\"font-weight:600\">When:</span> Friday, June 4, 2021 7:59 PM EDT. Delayed 15 minutes.<br/> <span style=\"font-weight:600\">After hours:</span> 126.01\r\n </p>\r\n <p>Data from Refinitiv</p>\r\n</div>",
"potentialAction": [
{
"#type": "OpenUri",
"targets": [
{
"os": "default",
"uri": "https://www.msn.com/en-us/money/stockdetails/fi-a1mou2"
}
],
"name": "More details",
"#id": "ViewOnMsn"
},
{
"#type": "OpenUri",
"targets": [
{
"os": "default",
"uri": "https://www.bing.com/news/search?q=Apple Inc"
}
],
"name": "News",
"#id": "ViewNews"
}
],
"markdown": false
}
]
}
eg 3: Card of Youtube app
JSON for the card
{
"title": "M1 MacBook Pro and Air review: Apple delivers",
"subtitle": "The Verge | 1.4M views | 6 months ago",
"text": "<p>Apple has updated three Mac with its own M1 processors: the Macbook Air, the entry-level 13-inch MacBook Pro, and the Mac mini. Will Intel-based apps run? Will ...</p>\r\n\r\n\r\n<p>YouTube | 12:57</p>",
"images": [
{
"alt": "M1 MacBook Pro and Air review: Apple delivers",
"url": "https://i.ytimg.com/vi/OEaKQ0pxQsg/hqdefault.jpg"
}
],
"buttons": [
],
"tap": {
"type": "openUrl",
"title": "M1 MacBook Pro and Air review: Apple delivers",
"value": "https://www.youtube.com/watch?v=OEaKQ0pxQsg"
}
}
Can I convert any other card type to an Adaptive Card JSON (either by a library or coding the con so I can display with Adaptive Card JS SDK? But then if I do it by code myself will I able to handle all card types/scenarios?
Bot Framework Web Chat renders all Bot Framework rich cards by converting them into Adaptive Cards first. Web Chat is open source, so you can have a look at the source code to see how it does that. However, the sample card you've shown from the Stocks app is a Teams-specific O365 Connector card and not a Bot Framework card, and the Teams source code is proprietary so you will not easily find out how that JSON gets processed. You can refer to the Teams docs to get an idea of the range of card types you're likely to encounter.
Is there any JS library that could show JSONs of cards other than Adaptive cards also
No, there is not. You might consider opening the Teams web app in your browser so you can read the HTML of the conversations you've collected from your API and compare the HTML to the JSON. You might also consider using a tool to just copy the HTML from your conversations directly instead of using the API to get the conversations in JSON form.

Expressions of JSONPath for rest assured in a list with maven dependesies

I am trying to fetch data which is in JSON format. I am using maven dependency, testng and rest-assured. I want to test Rest API.BUT getting an error of
java.lang.NullPointerException
Here is my code -
public class CountBook {
#Test
public void BookCount (){
// Specify the base URL to the RESTful web service
RestAssured.baseURI = **URL HERE**
// Get the RequestSpecification of the request
RequestSpecification httpRequest = RestAssured.given();
Response response = httpRequest.get("");
// First get the JsonPath object instance from the Response interface
JsonPath jsonPathEvaluator = response.jsonPath();
List<HashMap<String, Object>> allBook = jsonPathEvaluator.get("books.findAll {it.pages == 352}");
int countingBook = allBook.size();
System.out.println(countingBook);
}
}
How can I get rid of this?int countingBook = allBook.size(); this line shows error. Here the list return null value.JSON is look like this
{
"books": [
{
"isbn": "9781593275846",
"title": "Eloquent JavaScript, Second Edition",
"subtitle": "A Modern Introduction to Programming",
"author": "Marijn Haverbeke",
"published": "2014-12-14T00:00:00.000Z",
"publisher": "No Starch Press",
"pages": 472,
"description": "JavaScript lies at the heart of almost every modern web application, from social apps to the newest browser-based games. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.",
"website": "http://eloquentjavascript.net/"
},
{
"isbn": "9781491950296",
"title": "Programming JavaScript Applications",
"subtitle": "Robust Web Architecture with Node, HTML5, and Modern JS Libraries",
"author": "Eric Elliott",
"published": "2014-07-01T00:00:00.000Z",
"publisher": "O'Reilly Media",
"pages": 254,
"description": "Take advantage of JavaScript's power to build robust web-scale or enterprise applications that are easy to extend and maintain. By applying the design patterns outlined in this practical book, experienced JavaScript developers will learn how to write flexible and resilient code that's easier-yes, easier-to work with as your code base grows.",
"website": "http://chimera.labs.oreilly.com/books/1234000000262/index.html"
},
{
"isbn": "9781593277574",
"title": "Understanding ECMAScript 6",
"subtitle": "The Definitive Guide for JavaScript Developers",
"author": "Nicholas C. Zakas",
"published": "2016-09-03T00:00:00.000Z",
"publisher": "No Starch Press",
"pages": 352,
"description": "ECMAScript 6 represents the biggest update to the core of JavaScript in the history of the language. In Understanding ECMAScript 6, expert developer Nicholas C. Zakas provides a complete guide to the object types, syntax, and other exciting changes that ECMAScript 6 brings to JavaScript.",
"website": "https://leanpub.com/understandinges6/read"
},
{
"isbn": "9781491904244",
"title": "You Don't Know JS",
"subtitle": "ES6 & Beyond",
"author": "Kyle Simpson",
"published": "2015-12-27T00:00:00.000Z",
"publisher": "O'Reilly Media",
"pages": 278,
"description": "No matter how much experience you have with JavaScript, odds are you don’t fully understand the language. As part of the 'You Don’t Know JS' series, this compact guide focuses on new features available in ECMAScript 6 (ES6), the latest version of the standard upon which JavaScript is built.",
"website": "https://github.com/getify/You-Dont-Know-JS/tree/master/es6%20&%20beyond"
},
{
"isbn": "9781449337711",
"title": "Designing Evolvable Web APIs with ASP.NET",
"subtitle": "Harnessing the Power of the Web",
"author": "Glenn Block, et al.",
"published": "2014-04-07T00:00:00.000Z",
"publisher": "O'Reilly Media",
"pages": 538,
"description": "Design and build Web APIs for a broad range of clients—including browsers and mobile devices—that can adapt to change over time. This practical, hands-on guide takes you through the theory and tools you need to build evolvable HTTP services with Microsoft’s ASP.NET Web API framework. In the process, you’ll learn how design and implement a real-world Web API.",
"website": "http://chimera.labs.oreilly.com/books/1234000001708/index.html"
}
]
}
How can I resolve this problem?? Here is my stack trace
java.lang.NullPointerException
at CountBook.BookCount(CountBook.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:597)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:816)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.util.ArrayList.forEach(ArrayList.java:1249)
at org.testng.TestRunner.privateRun(TestRunner.java:766)
at org.testng.TestRunner.run(TestRunner.java:587)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1109)
at org.testng.TestNG.runSuites(TestNG.java:1039)
at org.testng.TestNG.run(TestNG.java:1007)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:110)
In order to find one book you can use:
jsonPathEvaluator.get("books.find {it.pages == 352}").toString();
You can also make expected number of pages parameterized like this:
jsonPathEvaluator.param("expected", 352).get("books.find {it.pages == expected}").toString();
In order to find List<> you just use findAll instead of find
EDIT:
You used findAll method which returns a list of elements. You saved them to List<String> which is NOT a correct class.
Each book is a JSON Object and using. Each JSON Object is a HashMap<> of the String is a name of parameter, like pages or isbn. The other parameter is an Object because in your JSON there are Strings like author but also Integers like pages.
So, the correct code to collect the List would look like this:
List<HashMap<String, Object>> allBooks = jsonPathEvaluator.get("books.findAll {it.pages == 352}");
allBooks.forEach(book -> book.forEach((key, value) -> System.out.println(key + " " + value)));
and to count the number of books simply do what you did before:
int bookCount = allBooks.size();

Integration from CRM to Team Foundation Server 2018

We have CRM where customers create tickets (change requests, incidents...).
From developer team side we have Team Foundation Server 2018.
To speed up process we would like to automatize entire thing. So, when customer create ticket, to automatic create TFS User Story.
We developed code to take, every time when ticket is created, data and put into JSON file. (will attach code in Github and share a link)
But now, I just need info, is someone have an idea, how JSON file should looks like which need to post to TFS in order to create new user story.
{
"fields": {
"System.WorkItemType": "User Story",
"System.AreaPath": "EJ2TFS",
"System.TeamProject": "EJ2TFS",
"System.IterationPath": "EJ2TFS",
"System.State": "New",
"System.Reason": "New",
"Microsoft.VSTS.Common.StateChangeDate": "2019-01-01T00:00:00Z",
"System.ChangedBy": "Doe, John <firm\\doej>",
"System.CreatedBy": "Doe, John <firm\\doej>",
"System.Title": "Sample task created by POST API",
"System.Discussion":"test1",
"Microsoft.VSTS.Common.StateChangeDate": "2019-01-31T14:00:00",
"Microsoft.VSTS.Common.Priority": 2,
"Microsoft.VSTS.Common.ValueArea": "Business"
}
}
And error is:
{
"$id": "1",
"innerException": null,
"message": "The request indicated a Content-Type of \"text/plain\" for method type \"POST\" which is not supported. Valid content types for this method are: application/json-patch+json.",
"typeName": "Microsoft.VisualStudio.Services.WebApi.VssRequestContentTypeNotSupportedException, Microsoft.VisualStudio.Services.WebApi",
"typeKey": "VssRequestContentTypeNotSupportedException",
"errorCode": 0,
"eventId": 3000
}
Looks like your payload need a makeover. I referred couple of code samples & sharing this snippet. (Pls test this, I didn’t get a chance to test it)
POST https://dev.azure.com/fabrikam/{project}/_apis/wit/workitems/$User Story?api-version=5.0
[
{
"op": "add",
"path": "/fields/System.Title",
"from": null,
"value": "My first user story"
}
]
MS documentation example
GitHub sample

How can I connecting NanoPool.org API to Telegram by Json

I'm using cryptocurrency mining website NanoPool.org
I should check the Data of this site for example Hashrate, workers and other things like that
I want to know how can I connect this site to my telegram.
Actually I don't know nothing about that, the only thing I aware about is that, the site have API with json but I searched a lot on Google couldn't find accurate training about that.
This is API link of this website.
Would you please help me how can I do that?
Thanks
User Data example code:
{
"account": "4AHBwkKjWT2jHv83V6ahZXUWCYe9JmyNygQJ7ueQUMhHJrJQJrWnYHHUMuaZhCGSnvKTjodddyxqwdz8y2o7aKRV6C1xntS",
"unconfirmed_balance": "0.36812920",
"balance": "5.87838746",
"hashrate": "2767380.0",
"avgHashrate": {
"h1": "2777915.0",
"h3": "2773365.0",
"h6": "2726529.2",
"h12": "2648470.4",
"h24": "2764918.3"
},
"workers": [
{
"id": "is",
"hashrate": "1861860.0",
"lastShare": 1505534231,
"rating": 322640212,
"avg_h1": "1855980.0",
"avg_h3": "1860296.7",
"avg_h6": "1858237.5",
"avg_h12": "1854944.6",
"avg_h24": "1854664.6"
},
{
"id": "china",
"hashrate": "905520.0",
"lastShare": 1505534231,
"rating": 118148712,
"avg_h1": "921935.0",
"avg_h3": "913068.3",
"avg_h6": "868291.7",
"avg_h12": "793525.8",
"avg_h24": "910253.8"
}
]
}
You can implement it with use of python json, telepot and requests libs
1. Receive json file from nanopool api via requests lib
2. Parse it via json lib
3. Create bot via botfather
4. Send it via telepot library as message to yourself from created bot

Firebase - Invalid JSON data or key values. Key values can’t contain $ # [ ] / or

I'm trying to import my JSON file into my Firebase but it keeps giving me this error. I don't know why this JSON file isn't allowed to be imported into since JSONLint says it's a valid JSON file.
Here's the file:
{
"Featured" : {
"artist" : "james turell",
"artistEPK" : "artistsownepk.pdf",
"author" : "john queue author",
"date" : "7/28/2016",
"fullScreenImg" : "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687",
"linksToMedia" : [ "www.wallplay.com/project-name/james-t/press.html" ],
"linksToPress" : [ "" ],
"location" : "10 Main Street",
"mainImg" : "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687",
"pressImgs" : [ "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687" ],
"pressRelease" : "projectpressrelease.pdf",
"projectImgs" : [ "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687" ],
"projectSubheader" : "subheader of project",
"projectTitle" : "title of project",
"projectURL" : "",
"soundFile" : [ ],
"text" : "here there would be a text for james turell",
"videoURL" : ""
},
"Future" : {
},
"Past" : {
},
"Present" : {
}
}
the issue happens when importing json using the web interface
I just spent some time on this and found the issue for me (and likely for many others) when getting this error message. It looks like firebase can only import files with UTF-8 encoding (no BOM)
I found it strange, as I couldn't re-import the content I had just exported.
I tried all UTF versions 8, 16 with LE and BE with and without BOM, only UTF-8 works
I wish firebase did not have this utterly misleading error message
Two things that might help someone else save a couple of hours of head scratching:
1) Empty strings are valid JSON keys, they're NOT valid Firebase keys.
2) While the web tool error message is horrible, the command-line tool actually provides useful information like, say, a line number (nice when you have a 300K+ line file)
E.g.
firebase --project database:set / import.json
to overwrite everything from the root
This happened to me, and had a totally different cause: I had Firebase functions that triggered when data is added to certain collections. The GUI tool gave me the unhelpful error the OP got. But running with the CLI, I got:
Error: HTTP Error: 400, This request would cause too many functions to be triggered.
So, the error ended up really saving my hide since running a function for each of the few hundred nodes I was importing would have been disastrous.
To solve the issue, I deployed my app code with the functions commented out and then was able to use the GUI to import my data. Once my data was in, I un-commented out the functions and deployed again.
My filename was "something-somethingelse", ie it had a '-' character in the filename. Changing it to 'something.json' solved the problem
So, don't have any special characters in your filenames.
The JSON you posted is valid for Firebase, so the issue is not with this JSON. It must be somewhere else in your application.
if you created triggered function a lot of. You have to remove triggered functions. Next try again. That way works for me.
I just found one more reason when Firebase throws this error:
This was the data firebase refused to upload:
{
"S. No.": 2,
"University Name": "Acharya Nagarjuna University, Guntur (Id: U-0003)",
"College Name": "Abhinav Institute of Management & Technology (Id: C-39450)",
"College Type": "Affiliated College",
"State Name": "Andhra Pradesh",
"District Name": "Prakasam"
}
I thought of changing the key name of "S. No." and it worked.
{
"S": 2,
"University Name": "Acharya Nagarjuna University, Guntur (Id: U-0003)",
"College Name": "Abhinav Institute of Management & Technology (Id: C-39450)",
"College Type": "Affiliated College",
"State Name": "Andhra Pradesh",
"District Name": "Prakasam"
}
The Firebase was accepting the later format (I believe the problem was with .(dot) followed by space.)
I hope this helps!!!
This was happening for me as well, as a web developer, I looked into the Developers Console and the actual error was because of authentication that Firebase's console was not able to authenticate while validating the JSON files.
So I did a "refresh" of the web page and it worked.
I have a similar problem with JSON containing huge data. I solved this problem by using firebase import tool. It has options for imports to specific nodes etc.