Create an ajax call - api

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.

Related

Is there a Cognito SDK that uses the `amazoncognito.com/oauth2/token` endpoint?

Accoding to the following docs, I can exchange a code for an access_token using this curl:
curl -X POST \
https://mysubdomain.auth.us-east-2.amazoncognito.com/oauth2/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'authorization: Basic ...' \
-d 'grant_type=authorization_code&client_id=client_id&code=code&redirect_uri=https%3A%2F%2Fwww.somewhere.com'
https://docs.aws.amazon.com/cognito/latest/developerguide/token-endpoint.html
I got this working no problem in Postman. Now I want to replicate this HTTP request in a dotnet core WebApi application and I'm having a very hard time finding any SDK to manage this. I could build and issue HttpRequest + deserialize the response json to models, but I find it hard time believing there isn't some AWS library that handles and maintains this much better than I ever could.
Is there an SDK for the amazoncognito.com/oauth2/token endpoint, preferably for dotnet core?
Unfortunately, not yet. You should use make a native HTTP call with POST method.
Here is the git issue for the same (for Java):
https://github.com/aws/aws-sdk-java/issues/1792

URLFetchApp with certificate: Google scripts with Apple ads reporting API

Hi I'm attempting to pull data from the Apple Ads API into a Google sheet, and I'm getting completely stuck on providing the security certificates. I've been able to successfully pull my data using Postman, so I'm comfortable that I can structure the request properly.
I'm trying to use URLFetchApp, but I can't see any means of including the PEM and KEY file, or even using the curl example provided by Apple of combining to the P12 file. Am I missing something here or is URLFetchApp unable to complete this?
It doesn't appear to me that this would fit into any of the existing headers for URLFetchApp https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetchurl-params
curl \
--cert ./<FILENAME>.p12 \
--pass <PASSWORD> \
-H "Authorization: orgId=<ORG_ID>" \
-H "Content-Type: application/json" \
-d "<CAMPAIGN_DATA_FILE>.json" \
-X POST "https://api.searchads.apple.com/api/v1/campaigns"
You're right in that Google Apps Script (GAS) does not support client-side SSL certificates in their UrlFetchApp class, which appears to be their only way to make outbound HTTP(S) requests.
Your best bet is probably to make a custom Google Apps Engine (GAE) in a language of your choice and expose an endpoint from there which when called from GAS will make a new request to your destination and provide the needed certificates. However, GAE is not free like GAS (since Google changed their cloud terms of service a couple years back), so that's something to keep in mind.

Sending push using countly API

I am trying to send a notification using the countly API ,
I found this in the documentation :
curl --request POST \ --url 'https://try.count.ly/i/pushes/prepare?args.apps=args.apps&args.platforms=args.platforms&args=args&api_key=api_key'
It says that i have to provide args which is a JSON object as string with future message data.
They don't provide any clear documentation about how should this arguments be
Any help would be appreciated
Throughout the system Countly expects a stringified JSON object in args parameter. You can look at how it works by sending a message from dashboard and looking at requests in Chrome developer tools, for example. But here we go:
curl --form 'args={"apps":["57fb679323b5388e28e2c37e"],"platforms":["a"],"tz":false,"test":false}' http://HOST/i/pushes/prepare?api_key=API_KEY
and then
curl --form 'args={"apps":["57fb679323b5388e28e2c37e"],"platforms":["a"],"tz":false,"test":false,"_id":"58cb862e2a16277d4501d787","type":"message","messagePerLocale":{"default":"Message text"},"locales":[{"value":"default","title":"Default","count":1062,"percent":100},{"value":"en","title":"English","count":296,"percent":28},{"value":"ja","title":"Japanese","count":166,"percent":16},{"value":"it","title":"Italian","count":152,"percent":14},{"value":"fr","title":"French","count":152,"percent":14},{"value":"de","title":"German","count":149,"percent":14},{"value":"ko","title":"Korean","count":147,"percent":14}],"sound":"default","source":"dash","date":"2017-03-24T07:00:00.000Z"}' http://HOST/i/pushes/create?api_key=API_KEY
You can also omit first request as described in documentation.

How to make Twitter API call through curl in unix

I would like to pull the data from Twitter REST API. I have created the consumer key, secret and Access token, secret. I have tried with "Test OAuth", it generates a CURL command but if I change any one parameter then it is giving the below error.
Message: {"errors":[{"code":32,"message":"Could not authenticate you."}]}
Now I would like to call the twitter API using CURL in shell script for different screenNames.
I want a sample command some thing like mentioned below
curl --get 'https://api.twitter.com/1.1/statuses/user_timeline.json' --data 'count=2&screen_name=aswin' APIKEY:"xxxxxx",Acesstoken:"yyyyyyyy"
Thanks in advance.
Regards,
Aswin
I found the answer.
curl --get 'https://api.twitter.com/1.1/statuses/user_timeline.json' \
--data 'count=2&screen_name=twitterapi' \
--header 'Authorization: OAuth oauth_consumer_key="AAAAAAAAAAAAAAAAAAAA", oauth_nonce="BBBBBBBBBBBBBBBBBBBBBBB", oauth_signature="CCCCCCCCCCCCCCCCCCCCCCCCCCC", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1471672391", oauth_token="DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD", oauth_version="1.0"'
Since your specific query doesn't require a user context you can use Application only authentication to make this request. The bearer token won't change per request so it should allow you to keep using curl.
https://dev.twitter.com/oauth/application-only
n.b. it won't work for all endpoints, but should for the case you listed.
Because most twitter requests require calculating the oauth signature, you should either write a client yourself or reuse an existing command line client.
https://github.com/twitter/twurl
https://github.com/sferik/t
https://github.com/yschimke/oksocial/wiki (Mac focused/cross service)
As you saw any change to the request will generally invalidate the query, and even time is one of the inputs.

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.