Is there a test JsonRpc server out there? - json-rpc

Is there any server on the Internet that uses JsonRpc and is publically available?
I want to test a JsonRpc client.
Does Google have any page that allows reading of anything with JsonRpc? Does YouTube? Does Facebook? Does W3C?
The JsonRpc server that i want to talk to isn't responding; and i'm trying to figure out if it's because they don't support JsonRpc.

Random.org has a nice api for generating random numbers.
For example, using Python with jsonrpcclient:
>>> import requests
>>> from jsonrpcclient import request, parse
>>> response = requests.post("http://api.random.org/json-rpc/1/invoke", request("generateIntegers", params={"apiKey": "(yourkey)", "n": 3, "min": 0, "max": 10}))
>>> parsed = parse(response.json())
>>> parsed.result
{'bitsLeft': 249920, 'advisoryDelay': 0, 'bitsUsed': 10, 'random': {'data': [9, 4, 2], 'completionTime': '2015-04-09 00:52:22Z'}, 'requestsLeft': 992}

Atlassian Confluence supports it, but I'm not sure they have a test instance. Plus, their implementation isn't quite 100% correct (https://developer.atlassian.com/x/AwCF)

Related

Facebook API metric for result/conversions

I've got Facebook campaigns set up to catch All URL Traffic where URL contains, which is my custom conversion. It generates a Custom Conversions ID and a Data Source Pixel ID. Based on those I can see "results" generated in the admin panel under literally a Results section.
Now I've got this connected to Snowflake using Stitch, and it pulls a ton of json-like elements, but I can't seem to match any of those to the Result section. Where am I supposed to look? Or am I missing something with the integration? Json-like element sample:
[{
"1d_click": 1,
"1d_view": 3,
"28d_click": 2,
"28d_view": 4,
"7d_click": 1,
"7d_view": 4,
"action_destination": "xxxxxxxxxxxxxxxxx",
"action_target_id": "xxxxxxxxxxxxxxxxx",
"action_type": "lead",
"value": 4
},
{
"1d_click": 1,
"1d_view": 4,
"28d_click": 2,
"28d_view": 5,
"7d_click": 1,
"7d_view": 5,
"action_destination": "xxxxxxxxxxxxxxxxx",
"action_target_id": "xxxxxxxxxxxxxxxxx",
"action_type": "offsite_conversion",
"value": 5
}]
To give you even more context, the spec above comes from an ADS_INSIGHTS table -> UNIQUE_ACTIONS column, while there are also many other tables (please see an image below), and so to filter it down to the above json selection, I am joining ADS_INSIGHTS and ADS on Ads IDs, which lets me filter the data by an ad name and check active ads only.
So my question is: where in all of this do I find equivalent of the Results? Which conversions should I be looking at? I read the documentation here, but still not getting it and my overall conversions do not match up between the native Fb dashboard interface and what I see in Snowflake. I.e. I know that I need to see 9 conversions in the Snowflake for a given campaign name, but different combinations do not render these 9 when I play with the received data. Please share thoughts.
UPD: the best I could get so far is by reading this link and looking at offsite_conversion.custom.<custom_conv_id> in table ADS_INSIGHTS, column ACTIONS.

Smartsheet API response codes with python SDK?

I am using the Smartsheet python SDK to do bulk operations (deletes, updates, etc.) on a Smartsheet. As my process becomes more complex, I've realized that I need to include some internal checks to make sure I am not encountering errors when sending multiple calls per minute as Smartsheet suggests in their API Best Practices.
My question is this: How do I access and parse the API responses while using SDK functions such as Sheets.delete_rows()? For instance, some of my requests using this function can trigger status: 500 Internal Server Error which mean the request was properly formatted but the operation failed on the Smartsheet end.
I can view these responses in my log file (or in terminal while running interactively) but how do I access them from within my script so I can, for example, sleep() my process for xx seconds if encountering such a response?
If you are looking to know the results of a request you can store the response in a variable and inspect that for determining the next steps your process should take. In the case of the DELETE Rows request a Result object is returned.
deleteRows = smartsheet_client.Sheets.delete_rows({{sheetId}}, [ {{rowId1}}, {{rowId2}}, {{rowId3}}])
print(deleteRows)
If the request was successful the response would look like this:
{"data": [7411278123689860], "message": "SUCCESS", "result": [7411278123689860], "resultCode": 0}
If there was an issue, rows weren't found for example, the response would look like this:
{"result": {"code": 1006, "errorCode": 1006, "message": "Not Found", "name": "ApiError", "recommendation": "Do not retry without fixing the problem. ", "refId": "jv6o8uyrya2s", "shouldRetry": false, "statusCode": 404}}
All of the Smartsheet SDKs will backoff and retry by default. Other errors will be thrown as exceptions.
There is a way to increase the default timeout (to allow more retries) when creating the client. However, the Python-specific way to do it doesn't seem to be documented yet. I'll add it to the queue. In the meantime, I think the Ruby example below will be the closest to how Python probably does it, but you might want to read through the various ways to do this.
C#: https://github.com/smartsheet-platform/smartsheet-csharp-sdk/blob/master/ADVANCED.md#sample-retryhttpclient
Java: https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/master/ADVANCED.md#sample-retryhttpclient
Node.js: https://github.com/smartsheet-platform/smartsheet-javascript-sdk#retry-configuration
Ruby: https://github.com/smartsheet-platform/smartsheet-ruby-sdk#retry-configuration

Security of cloudant query from OpenWhisk

I'm building an Angular SPA with a Cloudant data store on Bluemix.
Since the Bluemix implementation of OpenWhisk doesn't use VCAP services, I see 3 options to use OpenWhisk as my api provider for cloudant queries for my Angular app:
Follow the pattern of passing credentials as seen here: https://github.com/IBM-Bluemix/openwhisk-visionapp (very interesting approach btw)
Include the credentials as though I'm running locally as seen here: https://github.com/IBM-Bluemix/nodejs-cloudant/blob/master/app.js
Use the http API as seen here: https://docs.cloudant.com/api.html (which highlights the security problem passing credentials.
Since my service is not intended for publishing (it's intended for my own app) I'm thinking option 2 is my "least of all evils" choice. Am I missing something? My thinking is such that while fragile to changes it would be the most secure since credentials aren't passed in the open. The serverless infrastructure would have to be hacked...
Thanks in advance!
(lengthy) Update: (apologies in advance)
I've gotten a little farther along but still no answer - stuck in execution right now.
To clarify, my objective is for the app to flow from Angular Client -> OpenWhisk -> Cloudant.
In this simplest use case, I want to pass a startTime parameter and an endTime parameter, have OpenWhisk fetch all the records in that time range with all fields, and passing back selected fields. In my example, I have USGS earthquake data in a modified GeoJSON format.
Following information from the following articles below, I've concluded that I can invoke the wsk command line actions and use the bindings I've setup from within my Javascript function and therefore not pass my credentials to the database. This gives me a measure of security (still question the rest endpoint of my OpenWhisk action) but I figure once I get my sample running I think through that part of it.
My command line (that works):
wsk action invoke /my#orgname.com_mybluemixspace/mycfAppName/exec-query-find --blocking --result --param dbname perils --param query {\"selector\":{\"_id\":{\"$gt\":0},\"properties.time\":{\"$gt\":1484190609500,\"$lt\":1484190609700}}}
This successfully returns the following:
{
"docs": [
{
"_id": "eq1484190609589",
"_rev": "1-b4fe3de75d9c5efc0eb05df38f056a65",
"dbSaveTime": 1.484191201099e+12,
"fipsalpha": "AK",
"fipsnumer": "02",
"geometry": {
"coordinates": [
-149.3691,
62.5456,
0
],
"type": "Point"
},
"id": "ak15062242",
"properties": {
"alert": null,
"cdi": null,
"code": "15062242",
"detail": "http://earthquake.usgs.gov/earthquakes/feed/v1.0/detail/ak15062242.geojson",
"dmin": null,
"felt": null,
"gap": null,
"ids": ",ak15062242,",
"mag": 1.4,
"magType": "ml",
"mmi": null,
"net": "ak",
"nst": null,
"place": "45km ENE of Talkeetna, Alaska",
"rms": 0.5,
"sig": 30,
"sources": ",ak,",
"status": "automatic",
"time": 1.484190609589e+12,
"title": "M 1.4 - 45km ENE of Talkeetna, Alaska",
"tsunami": 0,
"type": "earthquake",
"types": ",geoserve,origin,",
"tz": -540,
"updated": 1.484191127265e+12,
"url": "http://earthquake.usgs.gov/earthquakes/eventpage/ak15062242"
},
"type": "Feature"
}
]
}
The action I created in OpenWhisk (below) returns an Internal Server Error. I'm passing the input value as
{
"startTime": "1484161200000",
"endTime": "1484190000000"
}
Here's the code for my action:
`var openWhisk = require('openwhisk');
var ow = openWhisk({
api_key:'im really a host'
});
function main(params) {
return new Promise(function(resolve, reject) {
ow.actions.invoke({
actionName:'/my#orgname.com_mybluemixspace/mycfAppName/exec-query-find',
blocking:true,
parameters:{
dbname: 'perils',
query: {
"selector": {
"_id": {
"$gt": 0
},
"properties.time": {
"$gt": params.startTime,
"$lt": params.endTime
}
}
}
}
}).then(function(res) {
//get the raw result
var raw = res.response.result.rows;
//lets make a new one
var result = [];
raw.forEach(function(c) {
result.push({id:c.docs._id, time:c.docs.properties.time, title:c.docs.properties.title});
});
resolve({result:result});
});
});
}`
Here are the links to my research:
http://infrastructuredevops.com/08-17-2016/news-openwhisk-uniq.html
Useful because of the use of the exec-query-find and selector syntax usage but also cool for the update function I need to build for populating my data!
https://www.raymondcamden.com/2016/12/23/going-serverless-with-openwhisk
The article referenced by #csantanapr
Am I overlooking something?
Thanks!
I'm assuming what you are trying to do is to access your Cloudant DB directly from your angular client side code from the Browser.
If you don't need any business logic, or you can get away by using Cloudant features (design docs, views, map, reduce, etc..) and you are generating Cloudant API keys with certain access (i.e. write vs. read), then you don't need a server or serveless middlewear/tier.
But now let's get real, most people need that tier, and if you are looking a OpenWhisk, then you are in good luck this is very easy to do.
OpenWhisk on Bluemix support VCAP service credentials, but in a different way.
Let's name you have a Bluemix Org carlos#example.com and space dev that would translate to OpenWhisk namespace carlos#example.com_dev
If you add a Cloudant service under the space dev in Bluemix, this will generate service key credentials for this Cloudant Account. This credentials give you super power access meaning you are admin.
If you want to use this Cloudant credentials in OpenWhisk, you can use the automatic binding generated with the cloudant package.
To do this using the OpenWhisk CLI run wsk package refresh this will pull the Cloudant credentials and create you a new package with the credentials binded as default parameter for all the cloudant actions under that package. This is modified version of #1 above
Another alternative is to bind the credentials manually to a package or an action as default parameters, this makes sense when you don't want to use the super power admin credentials, and you generated a Cloudant API key for a specific database. This is option #1 above.
I would not recommend to put the credentials in source code #2
For option #3, what's insecure is to pass your credentials as part of the URL like https://username:password#user.cloudant.com, but passing the username and password in the Authorization header over https is secured.
This is because even if you are using secure transport https everything in the URI/URL is not encrypted anyone can see that value, but passing secrets in body or header is standard practice as this is transfer after secure connection is established.
Then you create actions that use the credentials as parameters in your OpenWhisk actions to build your business logic for your backend.
Then how to do you access this backend from the Browser, well OpenWhisk has a API Gateway feature in experimental that allows your to expose your actions as public APIs with CORS enable.
Only a url is expose, your credentials as default parameters are never expose.
If you want to see an example on check out Raymond Camden Blog posts where he show Ionic/Angular App accessing his Cloudant Database of Cats
https://www.raymondcamden.com/2016/12/23/going-serverless-with-openwhisk

How to POST point location to Salesforce REST API?

What is the right JSON format to post a geolocation (point) to the Salesforce REST API? I am getting either deserialization or permission errors (despite wide open administrator permissions in my sandbox).
I tried:
{"location__c": {"latitude": 34, "longitude": 23}} # the actual return when a GET the field
and
{"location__c__latitude": 34, "location__c__longitude": 23}
and
{"latitude__c": 34, "longitude__c": 23} # this one out of desperation.
Obviously with all the necessary boilerplate and authentication. Posting to other custom fields works just fine.
As per https://help.salesforce.com/apex/HTViewHelpDoc?id=custom_field_geolocate_overview.htm&language=en
you need to specify them in a slightly different format, like so:
location__latitude__s, location__longitude__s
So, if you have an object with a geolocation (let's say an object called "house"), you'd do
{"house":{"location__latitude__s":34, "location__longitude__s":23}}

How to get total number of tracks in a playlist using soundcloud json API

I am trying to paginate the track list of a set/playlist obtained via soundcloud JSON API. Pagination technique described here works fine if I want to generate tracklist of x number of tracks for next page only. What I am trying to do is to make a numbered pagination with multiple page links. I didn't find any parameter such as "track_count" which returns the total number of tracks for "/user/tracks". So, can anyone give me any insights on making a numbered pagination for a playlist when getting data via soundcloud JSON API? thanks
/users endpoint has "track_count" property in the returned representation of user:
$ curl "http://api.soundcloud.com/users/3207.json?client_id=YOUR_CLIENT_ID"
{
"id": 3207,
"permalink": "jwagener",
"username": "Johannes Wagener",
"uri": "http://api.soundcloud.com/users/3207",
"permalink_url": "http://soundcloud.com/jwagener",
"avatar_url": "http://i1.sndcdn.com/avatars-000001552142-pbw8yd-large.jpg?142a848",
"country": "Germany",
"full_name": "Johannes Wagener",
"city": "Berlin",
"description": "<b>Hacker at SoundCloud</b>\r\n\r\nSome of my recent Hacks:\r\n\r\nsoundiverse.com \r\nbrowse recordings with the FiRe app by artwork\r\n\r\ntopbillin.com \r\nfind people to follow on SoundCloud\r\n\r\nchatter.fm \r\nget your account hooked up with a voicebox\r\n\r\nrecbutton.com \r\nrecord straight to your soundcloud account",
"discogs_name": null,
"myspace_name": null,
"website": "http://johannes.wagener.cc",
"website_title": "johannes.wagener.cc",
"online": true,
"track_count": 12,
"playlist_count": 1,
"followers_count": 417,
"followings_count": 174,
"public_favorites_count": 26
}
This question is already old, but I hope this could help other people.
You could use either of this endpoint:
http://api.soundcloud.com/playlists/{playlist_id}?client_id={client_id}
https://api.soundcloud.com/playlists/{playlist_id}?oauth_token={oauth_token}
The 2nd API is undocumented, the first endpoint suddenly started to return 401 for no reason which is from the SoundCloud API documentation. I still provided the 1st endpoint as it's only not working at work, but behaves correctly at home IP address. I suggest if you'd use the 2nd API to generate and use a non-expiring token.
SoundCloud is not a reliable provider anymore as there's no app support for developers. You just have to figure things out by yourself.
On the JSON response, look for track_count. That'll give you the number of tracks in a playlist.