How can I get JSON data from Rallydev rest API without login - json

What I'm trying to do is to get JSON data (whatever it is just make sure I can get anything is ok) from Rallydev without login to make sure that Rallydev is on. I tried several ways, but each way requires a username and password. Would anyone provide a URI for this? Thank you, Guys. Anything you give would be appreciated.
String url = "link";
Client client = Client.create();
WebResource webResource = client.resource(url);
String s = webResource.get(String.class);
try {
// check if RallyDev service is up
if (s.contains("Hello it is now "))
_log.information("RallyDev is working... at " + new Date());
} catch (Exception e) {
_log.error(ErrorCodeEnum.INTERNAL_ERROR, "RallyDev service might be down!!! in " + new Date(), e);
}

Ok, so whether it's Jersey client or plain old HTTP GET against Rally, I'm coming back to my original comment that developing a Java app to do this is a bit overkill. You could accomplish the same thing with a one-line curl command in Linux:
curl -u 'rallyuser#company.com:rallypassword' https://rally1.rallydev.com/slm/webservice/1.33/hierarchicalrequirement.js?pagesize=1
A valid (Rally is up and responding) response to this might look like:
{"QueryResult": {"_rallyAPIMajor": "1", "_rallyAPIMinor": "33", "Errors": [], "Warnings": [], "TotalResultCount": 84, "StartIndex": 1, "PageSize": 1, "Results": [{"_rallyAPIMajor": "1", "_rallyAPIMinor": "33", "_ref": "https://rally1.rallydev.com/slm/webservice/1.33/hierarchicalrequirement/12345678910.js", "_refObjectName": "My Story Name", "_type": "HierarchicalRequirement"}]}}

Looks like you're using Jersey Client to setup a REST connection in Java. Are you really needing to do this without providing credentials? You'll need to pass credentials of some sort as any query-able endpoint in Rally is going to require HTTP Basic Authentication.
If you are looking for the appropriate REST syntax and endpoints to formulate a valid query, you may wish to look at our Webservices API documentation on REST queries:
https://rally1.rallydev.com/slm/doc/webservice/rest.jsp
As an example, a valid REST URL to do a query and get back JSON-formatted results is as follows. A GET against the following sample URL queries user stories owned by user: user#company.com:
https://rally1.rallydev.com/slm/webservice/1.33/hierarchicalrequirement.js?query=(Owner = "user#company.com")&pagesize=1
This would return the first matching User Story.
A simple example of accessing Rally REST services in Java is here:
http://www.rallydev.com/help/basic-rest-client-operations-java
And a full (alpha-release) Java REST API toolkit for Rally is here:
http://www.rallydev.com/developer/java-toolkit-rally-rest-api
All of the above seems like a bit overkill for just finding out if the Rally service is up. You can subscribe to Rally's status updates via RSS at http://status.rallydev.com as a good way to stay apprised of system status information.
I hope this helps - if the answer is off-target, please provide some further clarifying comments and we'll do our best to answer.

Related

Intermittent Request Failure with RDC endpoints

We've been doing some testing with the RDC endpoints in Banno and noticed a bizzare issue where, intermittently, a POST request will respond with a 400. Seconds later, submitting the same request will yield a new RDC account as expected. I'm doing my testing in PowerShell, and below are some examples.
New-RDCAccount -userId $userId -accountTypeMarker Checking -name "Text" -accountNumber "XXXXXXXXX"
And the response for this would work, however when I send a request minutes later:
New-RDCAccount -userId $userId -accountTypeMarker Checking -name "Text" -accountNumber "XXXXXXXXX"
#Note that $userId is the same throughout each request
I get this response: The remote server returned an error: (400) Bad Request.
I understand that the error code implies that my body is malformed, but how is it possible that in one request it's acceptable and in the next it's malformed?
Below is the body for each request (with redacted information). The first one is a working example, and the second one is the failed example:
{
"accountNumber": "XXXXXXXX",
"accountTypeMarker": "Checking",
"name": "Text"
}
{
"accountNumber": "XXXXXXXX",
"accountTypeMarker": "Checking",
"name": "Text"
}
Because I feel this issue is a little hard to believe, I've provided screenshots as well with this.
Not working:
Working:
I'm hopeful someone here can help me out here, cause I feel like I'm taking crazy pills looking at this.
Thank you!
Edit:
Here's another example of it working on one instance, and not another with 0 changes to the code (side by side):
Edit of edit:
I can replicate this issue pretty consistently through Banno People AND my own PowerShell script. I feel this is definitely something on the Banno side at this point...
Pictures for Jamies comment:
Working request headers:
Fail request headers (Note that accessing any of the elements yield a null result):
I'm using this endpoint: https://jackhenry.dev/open-api-docs/admin-api/api-reference/v0/rdc/details/#/User%20RDC%20Endpoints/post_a_mobile_api_v0_institutions__institutionId__users__userId__rdcAccounts

Postman interceptor request running forever

I am trying to intercept a website - https://www.kroger.com/pl/chicken/05002. In the chrome network tab, I see the request as below, with the details of the products nicely listed as JSON
I copied the cURL as bash and imported it as raw text in Postman. It ran forever without any response. Then I used the intercept feature and still it is running forever.
When both the requests are exactly same, why is it running in Chrome and not in Postman? What am i missing? Any help is appreciated, thanks in advance.
This is probably happening because they don't want you to do what you are trying to do. Note the "filter.verified" param in the URL.
You may want to try reaching out to them for an external API token - especially if you are creating an app or extension to compare competitive prices with the intention of distributing said app or extension - regardless of if it is for financial compensation or not.
Ethically questionable workaround (which would defintely need to be improved upon - this is simply an example of how you could solve your problem...):
GET https://www.kroger.com/search?query=chicken&searchType=default_search&fulfillment=all
const html = cheerio(responseBody);
var results = [];
html.find('div[class="AutoGrid-cell min-w-0"] > div').each(function (i, e)
{
results.push({
"Item": e.children[e.children.length-3].children[0].children[0].children[0]["data"],
"Price": e.children[e.children.length-4].children[0].attribs["value"]
})
});
console.log(results);
If you are unable to obtain an API token from them, this would probably be a legal way to accomplish what you want.

How do applications know how return the data an API requested?

Let's say I created Twilio. Below is their alerts API
https://www.twilio.com/docs/usage/monitor-alert:
Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client
Your Account Sid and Auth Token from twilio.com/console
and set the environment variables. See http://twil.io/secure
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account_sid, auth_token)
alert = client.monitor.alerts('NOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
print(alert.alert_text)
Example JSON API response:
{
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"alert_text": "alert_text",
"api_version": "2010-04-01",
"date_created": "2015-07-30T20:00:00Z",
"date_generated": "2015-07-30T20:00:00Z",
"date_updated": "2015-07-30T20:00:00Z",
"error_code": "error_code",
"log_level": "log_level",
"more_info": "more_info",
"request_method": "GET",
"request_url": "http://www.example.com",
"request_variables": "request_variables",
"resource_sid": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"response_body": "response_body",
"response_headers": "response_headers",
"request_headers": "request_headers",
"sid": "NOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"url": "https://monitor.twilio.com/v1/Alerts/NOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"service_sid": "PNe2cd757cd5257b0217a447933a0290d2"
}
How does the application return the data above? How does it know to return the above data?
DO you have to create an object with the data above to respond to said API call> Does the programmer need to write a special function, they would not normally create if they didn't want to provide API access to the application, to respond to the api call that will return the data?
So for example if I had a website that enabled people to enter in their first and last names into a database. I would then need to write a program that utilized some function that inserted the names. If I then wanted to create an API to give others to retrieve the names from the database I would need to create another function, that I wouldn't create if I didn't have the API, to retrieve the names for the API call. Or I would create an API call that would make a request to some function that would return an object with all the data I said my API call would return; or the function would go searching around for the data create an object and then return the information to the person who made the call.
Someone wrote it. Or maybe they wrote code that wrote it.
But probably someone just wrote it in at least one iteration; but as everything is translated, compiled and interpreted nowadays, what is the difference.
Some of the best external API-services evolved out of internal APIs; like AWS.
The hard part is not throwing together an API, it is testing it, ensuring it is robust and secure and privacy capable sufficiently powerful.

What is a useful Azure IoT Hub JSON message structure for consumption in Time Series Insights

The title sounds quite comprehensive, but my baseline question is quite simple, I guess.
Context
I Azure, I have an IoT hub, which I am sending messages to. I use a modified version one of the samples from the Azure Iot SDK for python.
Sending works fine. However, instead of a string, I send a JSON structure.
When I watch the events flowing into the IoT hub, using the Cloud shell, it looks like this:
PS /home/marcel> az iot hub monitor-events --hub-name weathertestiothub
This extension 'azure-cli-iot-ext' is deprecated and scheduled for removal. Please remove and add 'azure-iot' instead.
Starting event monitor, use ctrl-c to stop...
{
"event": {
"origin": "raspberrypi-zero-wh",
"payload": "{ \"timestamp\": \"1608643863720\", \"locationDescription\": \"Attic\", \"temperature\": \"21.941\", \"relhumidity\": \"71.602\" }"
}
}
Issue
The data seems fine, except the payload looks strange here. BUT, the payload is literally what I send from the device, using the SDK sample.
Is this the correct way to do it? At the end, I have a very hard time to actually get the data into the Time Series Insights model. So I guess, my structure is to be blamed.
Question
What is a recommended JSON data structure to send to the IoT hub for later use?
You should add the following 2 lines to your message in your python SDK sample:
msg.content_encoding = "utf-8"
msg.content_type = "application/json"
This should resolve your formatting concern.
We've also updated our samples to reflect this: https://github.com/Azure/azure-iot-sdk-python/blob/master/azure-iot-device/samples/sync-samples/send_message.py
I ended up using the tip by #elhorton, but it was not the key change. Nonetheless, the formatting in the Azure Shell Monitor looks now much better:
"event": {
"origin": "raspberrypi-zero-wh",
"payload": {
"temperature": 21.543947753906245,
"humidity": 69.22964477539062,
"locationDescription": "Attic"
}
}
The key was:
include the message source time in ISO format
from datetime import datetime
timestampIso = datetime.now().isoformat()
message.custom_properties["iothub-creation-time-utc"] = timestampIso
Using the locationDescription as the Time Series ID Property See https://learn.microsoft.com/en-us/azure/time-series-insights/how-to-select-tsid (Maybe I could also have taken the iothub-connection-device-id, but I did not test that alone specifically)
I guess using "iothub-connection-device-id" will make "raspberrypi-zero-wh" as the name of the time series instance. I agree with your choice of using "locationDescription" as TSID; so Attic becomes the time series instance name, temperature and humidity will be your variables.

Cannot find field: fullfillmentText in message, while it is present

I started using API.AI and Dialogflow in its first versions for some small time projects.
Recently I wanted to try and dive into the new V2 of Dialogflow and see how I can continue to build nice Google Assistant apps with that.
When trying to formulate a response (based on the documentation here https://dialogflow.com/docs/reference/api-v2/rest/v2beta1/WebhookResponse) I am unable to actually render responses of any kind. Everytime I do it just gives me a webhook error back.
The intent That I'm using in my demo project is (still fairly simple as I'm just trying to get a response back):
My Webhook (Elixir based) returns the following response (actual production response):
When inspecting the "Show JSON" After doing the test on the right-hand side of the Dialogflow screen I receive:
I must be doing something wrong, should the whole response that I send now be wrapped in something?
Update:
When removing "fullfillmentText" and just keeping "fullfillmentMessages" I seem to get the same error, but then for fullfillmentMessages. It looks like DialogFlow doesn't understand the JSON parameters I'm sending to it. example:
Man, what a typo here... Managed to fix it in the end by writing "fulfillmentMessage".
Protip for everyone starting with this and wanting to know the structure of data:
Make a simple intention, just as a test
Add some google or other responses trough the GUI
Save the intention
Trigger the intention from the "tryout now" function on the right-hand side.
Click SHOW JSON to inspect how a response would need to look.
Final result Code sample:
{
"fulfillmentMessages": [
{
"platform": "ACTIONS_ON_GOOGLE",
"simpleResponses": {
"simpleResponses": [
{
"displayText": "Sorry, something went wrong",
"ssml": "<speak>Sorry, Something went wrong <break time=\"200ms\"/> Please try again later</speak>"
}
]
}
}
]
}