I am trying to implement Calling an HTTP or REST API from Transaction Processor Functions
So when I am requesting GET https APIs it is working but when I am trying http APIs it is not working and throwing error:
RequestError: TypeError: Failed to fetch
and in browser console varies with APIs:
net::ERR_SSL_PROTOCOL_ERROR
net::ERR_CONNECTION_CLOSED
I have tested http APIs in postman and they are working perfectly fine.
This is the code:
transaction checkApi {
o String api
}
async function checkApi(tx) {
const apiObj = await request.get({ uri: tx.api, json: true });
console.log(apiObj);
});
Is it because of CORS? can someone please explain what is the issue?
I think you are trying to execute this transaction through composer playground with your network deployed to web browser instead of local fabric server.
if this is the case, you will get the error. because it could be CORS issue.
I ran into same issue.
But same request.get() worked for me when Transaction was tested on local fabric server.
other thing you should do is try using
request.get("yourURL"); Dont use json flag.
Related
I'm trying to trigger a jenkins job using the API. I got the set the token, got to run it successfully in the browser and got a json output from the API call using:
https://<MY_JENKINS_ADDRESS>/job/path/job_name/api/json/build?token=my_token
I tried to use this call in a POST or GET web activity in Azure Data Factory but I'm getting this error:
Error calling the endpoint '<MY_JENKINS_ADDRESS>'. Response status code: 'NA - Unknown'. More details: Exception message: 'NA - Unknown [ClientSideException] Invalid Url:https://<MY_JENKINS_ADDRESS>/job/path/job_name/api/json/build?token=my_token. Please verify Url or integration runtime is valid and retry. Localhost URLs are allowed only with SelfHosted Integration Runtime'.
Request didn't reach the server from the client. This could happen because of an underlying issue such as network connectivity, a DNS failure, a server certificate validation or a timeout.
It is clear data factory can't access the url. How can I solve this issue? Any thoughts?
I am assumimg that the <https://<MY_JENKINS_ADDRESS/job/path/job_name/api/json/build?token=my_token>> is not a publically available and if that the case you should know that with ADF you can only access public facing urls . What that means is that If there anything whch is running on my local network or say on my laptop , ADF will be not abe able to access that .
Next.js app works fine on local and also on data fetching (getStaticProps) on vercel. However, post data form submission via pages/api/add is not working
Getting this error:
FetchError: request to https://www.googleapis.com/oauth2/v4/token
failed, reason: Client network socket disconnected before secure TLS
connection was established
Confirm that credentials generated from Google API are added as env variables and are correct without any typo.
With some debugging found that
Max execution limit is not a problem when I pass hardcoded values to getStaticProps and it gets inserted (on vercel and local)
POST data to goolesheets via api/add is not working (I've tried npm-google-spreadsheet and also official googleapis npm packages)
I am working on an MVC Web Application which sends data as a producer to an Event Hub.
I have successfully set up event hub name space and event hub and was able to successfully send data while running a project in my local machine via local-host.
However when i deployed an application to Azure's Cloud i am getting the following error exception
while trying to send data:
Put token failed. status-code: 401, status-description: Unauthorized TrackingId:XXXX-XXXXX
Both Event Hub and Web Application is under the same subscription.
SAS Policy Connection string is from the root of a name-space.
Works fine locally, but receiving error on the Azure's Cloud when accessing that page.
Thanks in advance.
Couple of things you may need to check:
Make sure VNET and IP rules are properly configured.
Make sure both local and cloud deployments use the same connection string.
I'm working with ionic with capacitor and trying to pull a list files from a directory using the google drive api. I was able to pull a list of files on android but when I try to run on ios (using both an emulator and device) it gave me this error.
This is the code I'm using to hit that URI. Note I'm using a service account to auth my requests.
drive(access_token): Observable<Object> {
const headers = new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + access_token
})
return this.http.get("https://www.googleapis.com/drive/v3/files", { headers: headers }).pipe(
tap(data => data['files']),
catchError(this.handleError)
);
}
On my app I'm also hitting the google calendar api and I was able to pull information out of that so I know the access token is good.
I tried hitting on the uri with postman also and I was able to pull a list of files there.
Not sure what's the issue here, happy with any input.
I ended up using a different http client, I originally was using angulars httpClient but switch to ionic native http client and i was able to hit the google drive endpoint.
https://ionicframework.com/docs/native/http
I'm trying to use the oAuth functionality of adfs but are struggling to get an access token out of it.
The setup is a Windows Server 2012 R2 Preview Edition installed in a virtualbox vm.
I am able to get an access_code by issuing the following:
https://asdf.bla.dev/adfs/oauth2/authorize?response_type=code&client_id=abcd-abcd-abcd&redirect_uri=https://localhost/auth&resource=testservice.asdf.oauth
this redirects me to the following url
https://localhost/auth?code=U2dIhBsRt0eDnEhAEq2fcw.d3LeME__0QgBAC8zvLR6mTlRvC0.fLKd5eQRjXslTEeEck17m6Zo4fKKO9oGk2byUyr4CyLQHKSJs5wKzWZcusLXqXk22tdzvswxBjzaYcCqzkbeT5VxhMEdq97vbSnGAQ1tVD0vutVIfbx1Mb5A-QItgOx8a8LBapn7axCpGThoVH2jWCVM59X5eOt9ACuJTTK1UFbNaldaTkuGdqrtcGC8tFoSOP96G-4sHgIBpi2t8BSwCdf3asDd3AJAOYk6gnUkH5WJQRf2pg4S_AkgOxseeZW8Y5qbWAajyESkEmJ-UcWkV98uHlrmNsFwTSJ-ZoNk-aZI_U85ZlZrsdpKzocrWM5HmfcvXm5XdXz2QXIHngIBTA
but when I try to redeem the token with this request:
https://asdf.bla.dev/adfs/oauth2/token?grant_type=authorization_code&client_id=abcd-abcd-abcd&redirect_uri=https://localhost/auth&code=U2dIhBsRt0eDnEhAEq2fcw.d3LeME__0QgBAC8zvLR6mTlRvC0.fLKd5eQRjXslTEeEck17m6Zo4fKKO9oGk2byUyr4CyLQHKSJs5wKzWZcusLXqXk22tdzvswxBjzaYcCqzkbeT5VxhMEdq97vbSnGAQ1tVD0vutVIfbx1Mb5A-QItgOx8a8LBapn7axCpGThoVH2jWCVM59X5eOt9ACuJTTK1UFbNaldaTkuGdqrtcGC8tFoSOP96G-4sHgIBpi2t8BSwCdf3asDd3AJAOYk6gnUkH5WJQRf2pg4S_AkgOxseeZW8Y5qbWAajyESkEmJ-UcWkV98uHlrmNsFwTSJ-ZoNk-aZI_U85ZlZrsdpKzocrWM5HmfcvXm5XdXz2QXIHngIBTA
there is an error and I don't get an access-token.
The event viewer of the adfs service states the following error:
There are no registered protocol handlers on path /adfs/oauth2/token to process the incoming request....
I built the request following this information: https://github.com/nordvall/TokenClient/wiki/OAuth-2-Authorization-Code-grant-in-ADFS
I have no idea what's going wrong and would really appreciate your help!
I know that the thread is quite old but I was going through hell today when trying to resolve this error. I checked http.sys, reinstalled the server role,... nothing worked.
At the end, I had to find out that this crazy ADFS does (again) return garbage error messages. After 5 hours of debugging I didn't trust postman any longer (even if it worked without issues for months now) and used a short PowerShell script to invoke the POST with the access code:
$client = new-object net.webclient
$form = New-Object System.Collections.Specialized.NameValueCollection
$form.Add("client_id", "you client id")
$form.Add("grant_type", "authorization_code")
$form.Add("code", "authorization code")
$form.Add("redirect_uri", "your redirect uri")
$result = $client.UploadValues("https://sso.mydomain.com/adfs/oauth2/token", "POST", $form)
$decodedToken = $client.Encoding.GetString($result);
Et voila... all working. So I went back to the broken postman query, stripped all url parameters, removed all headers and added the parameters to the x-www-form-urlencoded tab. Then it worked there again.
Meaningful errors would definitely be helpful. Hope this saves someone many hours of frustrating try&error...
You are on the right track. You get code on redirect URI. Now we will have to make a POST request to the /token endpoint using the following parameters:
code - you will have to extract this value from the URL using some programming logic
client_id
redirect_uri
grant_type - use the value "authorization_code"
In response you should get a JWT access token.
It looks like you use HTTP GET to access the token endpoint, but it should be HTTP POST.