Submit a JSON to a Heroku page using Rails - sql

Well, i'm building an application in rails and i'm locked in a task.
The issue is that i need to upload a json file containing the result of a SQL query to this url: http://api-segura.herokuapp.com/consultaPetianos, where the view of my application will get the data requested.
I already have the json string, but my question is, how can I submit this string(or file) to the given url?
Obs: the application is hosted in Heroku.

If this is a one time deal, one easy option is to use curl.
There are quite a few questions on here about posting json using curl.
Check here for more info.
curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' URL

Related

How to import an Environment in Matillion

I am new to Matilion (Even Matillion is a new tool). I am able to export an existing environment into a JSON file using REST API.
But I observed that there is no REST API endpoint for importing an environment. Rather there is an option for updating an existing environment.
Any help/pointers will be appreciated.
Matillion REST API reference link : https://redshift-support.matillion.com/s/article/2920263
Regards,
Neeraj
I got the solution. No need to specify the environment name in API URL. It will automatically pick the name from JSON file. Below is an example.
curl -X POST -u <user_name>:<password> http://<Matillion Instance IP>/rest/v1/group/name/icm/project/name/<>/environment/import -H "Content-Type: application/json" --data-binary "<path to exported JSON file>"

Login Github with Curl

I tried call this command
curl -l -u "my_user_name" https://my-enterprise-github.com
Then, I input my password manually.
But it returns this
<html><body>You are being redirected.</body></html>
Please explain what's wrong with my command.
Thank you.
cURL should not be used for access to GitHub's (or most web) UI without specific reasons. GitHub provides an API to allow accessing data as a well-defined structure.
You mentioned wanting to get-a-single-pull-request. This relies on a URL pattern following GET /repos/:owner/:repo/pulls/:number.
So if you had a GitHub account, facebook, and wanted to look up a specific pull request 15947 in react-native. The full URL would be
https://api.github.com/repos/facebook/react-native/pulls/15947
The cURL command would be
curl -u osowskit -X GET https://api.github.com/repos/facebook/react-native/pulls/15947
Note that:
You will likely want to start using a PAT or OAuth token instead of username/password
There are tools that make exploring the GitHub API easier. postman or octokit
To start with you may want the -L flag. From the cURL Frequently Asked Questions
3.8 How do I tell curl to follow HTTP redirects?
Curl does not follow so-called redirects by default. The Location: header that informs the client about this is only interpreted if you're using the -L/--location option. As in:
curl -L http://redirector.com
Not all redirects are HTTP ones, see 4.14
There's also a CLI now that can be helpful for many similar use-cases:
https://cli.github.com/
$ gh pr list
Showing 2 of 2 open pull requests in Roblox/service-comms-nomad
#16 chi1 Traefik 1.7 GLB jobs chi1-glb-prep
#6 Cgt/t2 cgt/t2

Confluence REST API Authorization Failure

I am trying to use the Confluence REST API to create a page. I am using the curl example off of the documentation found HERE. Every time I try to run a terminal command using this curl I get a response that says 'HTTP Status 401 - Basic Authentication Failure - Reason : AUTHENTICATION_DENIED'. I see that someone else had a similar issue regarding their C# code, but there was never a resolution given. Hopefully someone with experience will be able to tell me what I am doing wrong. My curl is listed below with the sensitive parts replaced in <> format.
curl -u <USER>:<PASSWORD> -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"new page","space":{"key":"<PAGEKEY>"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' https://<SERVER>/wiki/confluence/rest/api/content/ | python -mjson.tool
I was finally able to resolve this. Through a combination of the answer here How to create new page in Confluence using their REST API? and using a login that had the appropriate permissions.

API Post Data to Middleware

Anyone know how I can test posting data to this url? I was given the link by the IT supervisor and trying to have the data posted to the following link by submitting the following form. He said it would accept anything I send it
Could could do this via curl:
curl -X POST -d "data=anything_i_send_it" http://powersource.braindongle.com/lead-manager/lead/new/omgpost/sessions/
Or using another HTTP tool like Hurl.it
Or using a Chrome extension like Postman or REST Console.
Advanced Rest Client is an easy way to do it. It's a free chrome extension that can form http requests with data.

Create an ajax call

i've never used an ajax call,can anybody suggest me to create a jquery ajax call using this api (parse.com),what is H,G?:
curl -X GET \
-H "X-Parse-Application-Id: qS0KLMx5h9lFLGJIpj9qyhM9EEPiTS3VMk" \
-H "X-Parse-REST-API-Key: nh3eoUo9GF2gMhcKJIfIt1Gm" \
-G \
--data-urlencode 'username=cooldude6' \
--data-urlencode 'password=p_n7!-e8' \
https://api.parse.com/1/login
curl is a tool for sending HTTP requests. The -H flag sets a header and -G specifies that the data should be transmitted as a URL query parameter rather than content body. In this case, your command sends an HTTP GET command with the custom headers "X-Parse-Application-Id" and "X-Parse-REST-API-Key". This request was sent to https://api.parse.com/1/login?username=cooldude6&password=p_n7!-e8.
You don't need to become a CURL expert to use Parse; the REST API helps you understand how the Parse API works across the wire, but there are both first and third party APIs for just about every language you would need.
P.S. The Parse docs page helps you by pre-filling the value of X-Parse-Application-Id and X-Parse-REST-API-Key with keys from your actual app. By posting these keys online, others can write code that will look like your app to Parse. Though best practices would suggest you secure your app so that it's OK for these keys to leak (e.g. by setting class-level permissions), you may consider deleting & recreating a new app since it sounds like you are just starting development.