"Network error" while calling a REST api from Outlook app, but 200 Ok from outllook web (Outlook.com) - outlook-web-addins

I was building an outlook add-in for which i need to call a rest api. While sideloading the add-in in the outlook application in my Mac it is throwing the error below. But, in the outlook.com it is working perfectly fine (200 Ok response). I might be missing something, don't know what. I couldn't fix it. Please help me fixing this problem.
Thanks!!
{
"message": "Network Error",
"name": "Error",
"stack": "createError#https://localhost:3000/vendor.js:613:24\nhandleError#https://localhost:3000/vendor.js:104:25\nwrapFn#https://localhost:3000/polyfills.js:1231:48\nonInvokeTask#https://localhost:3000/vendor.js:34970:43\nrunTask#https://localhost:3000/polyfills.js:180:61\ninvokeTask#https://localhost:3000/polyfills.js:493:45\ninvokeTask#https://localhost:3000/polyfills.js:1634:24\nglobalZoneAwareCallback#https://localhost:3000/polyfills.js:1660:31",
"config": {
"url": "http://localhost:8102/api/get-token",
"method": "post",
"headers": {
"Accept": "application/json, text/plain, */*"
},
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1
}
}

Related

Azure Logic App not able create client certificate authentication with converted base64 encoded pfx

I want to get the token information for ADP Client through Azure Logic App. I have the Client Certificate from ADP so I decided to use HTTP trigger from Logic App and selected authentication type "Client Certificate".
Since I cant directly use certificate in Logic app so I converted certificate into base64Encoded .pfx format, and certificate is not having any password.
below is the sample code for the request
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {
"HTTP": {
"inputs": {
"authentication": {
"pfx": "convertedbase64string",
"type": "ClientCertificate"
},
"body": "grant_type=client_credentials&client_id=ClientId&client_secret=client_secret",
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"method": "POST",
"uri": "https://accounts.adp.com/auth/oauth/v2/token"
},
"recurrence": {
"frequency": "Month",
"interval": 15
},
"type": "Http"
}
}
},
"kind": "Stateful"
}
above request returns me bad request, can anyone help me what is going wrong here?
For converting into base64 I used below steps in power shell
$pfx_cert = get-content 'C:\sample\adpcertificate.pfx' -Encoding Byte
$output =[Convert]::ToBase64String($pfx_cert)
$output
I tried same request with client certificate using postman which is working fine, but not able to get succeed with Logic App.
Any help is much appreciated.
There are only few differences between the headers sent from Postman and the Logic App. The main difference is that Postman also sends the accept-header: "Accept": "*/*" and leaves out alle the x-ms-* headers from the logic app.
I created a Logic App with http-trigger, which I post to from Postman and Logic App to inspect the changes:
With Postman
{
"headers": {
"Connection": "keep-alive",
"Accept": "*/*",
"Accept-Encoding": "br,gzip,deflate",
"Host": "....westeurope.logic.azure.com:443",
"User-Agent": "PostmanRuntime/7.28.4",
"Postman-Token": "...-baea-4e89-9bf6-490a63968b5d",
"Content-Length": "76",
"Content-Type": "application/x-www-form-urlencoded"
},
"body": {
"$content-type": "application/x-www-form-urlencoded",
"$content": "Z3JhbnRfdHlwZT1jbGllbnRfY3JlZGVudGlhbHMmY2xpZW50X2lkPUNsaWVudElkJmNsaWVudF9zZWNyZXQ9Y2xpZW50X3NlY3JldA==",
"$formdata": [
{
"key": "grant_type",
"value": "client_credentials"
},
{
"key": "client_id",
"value": "ClientId"
},
{
"key": "client_secret",
"value": "client_secret"
}
]
}
}
With Logic App
{
"headers": {
"Connection": "Keep-Alive",
"Accept-Encoding": "gzip,deflate",
"Accept-Language": "en",
"Host": "...westeurope.logic.azure.com",
"User-Agent": "azure-logic-apps/1.0,(workflow ...; version ...)",
"x-ms-trigger-callback-url": "https://....westeurope.logic.azure.com/ <...>",
"x-ms-trigger-type": "Http",
"x-ms-workflow-id": "...",
"x-ms-workflow-version": "...",
"x-ms-workflow-name": "myworkflowname",
"x-ms-workflow-system-id": "/locations/westeurope/scaleunits/...",
"x-ms-workflow-run-id": "...",
"x-ms-workflow-operation-name": "HTTP",
"x-ms-execution-location": "westeurope",
"x-ms-workflow-subscription-id": "...",
"x-ms-workflow-resourcegroup-name": "..",
"x-ms-tracking-id": "...",
"x-ms-correlation-id": "...",
"x-ms-client-request-id": "...",
"x-ms-activity-vector": "...",
"Content-Length": "76",
"Content-Type": "application/x-www-form-urlencoded"
},
"body": {
"$content-type": "application/x-www-form-urlencoded",
"$content": "Z3JhbnRfdHlwZT1jbGllbnRfY3JlZGVudGlhbHMmY2xpZW50X2lkPUNsaWVudElkJmNsaWVudF9zZWNyZXQ9Y2xpZW50X3NlY3JldA==",
"$formdata": [
{
"key": "grant_type",
"value": "client_credentials"
},
{
"key": "client_id",
"value": "ClientId"
},
{
"key": "client_secret",
"value": "client_secret"
}
]
}
}
Solution
My solution would be to manually add the Accept-Header in the post request in the Logic App.
"headers": {
"Accept": "*/*",
// ...
},
I sadly don't have an ADP account to verify this, but I've seen other APIs break when no accept header is sent.

Error "connect ECONNREFUSED" when sending a request using Axios

I am getting this error while sending requests to use Axios in Nodejs get request. I am calling the 3rd party API.
{
"message": "connect ECONNREFUSED 198.54.117.197:443",
"name": "Error",
"stack": "Error: connect ECONNREFUSED 198.54.117.197:443\n at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)",
"config": {
"url": "https://swapi.co/api/starships/9",
"method": "get",
"headers": {
"Accept": "application/json, text/plain, */*",
"User-Agent": "axios/0.21.0"
},
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"maxBodyLength": -1
},
"code": "ECONNREFUSED"
}
My code
https://github.com/bilalyaqoob/caching-with-node-js-redis
Can anybody help me?
You are using an outdated endpoint. On the website it states that you need to use https://swapi.dev/api/starships/9/ instead of ttps://swapi.co/api/starships/9 .
They moved from a .co to a .dev domain.

does pact-jvm-provider-maven_2.12 support multiple headers?

When there are multiple headers in the interaction, pact-jvm-provider-maven_2.12 version 3.5.25 throws an exception when I run mvn pact:verify to verify the contract at the provider side
Caused by: java.lang.NullPointerException: Cannot set property 'text' on null object
at org.codehaus.groovy.runtime.NullObject.setProperty (NullObject.java:80)
at org.codehaus.groovy.runtime.InvokerHelper.setProperty (InvokerHelper.java:197)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty (ScriptBytecodeAdapter.java:484)
at au.com.dius.pact.provider.reporters.JsonReporter.finaliseReport (JsonReporter.groovy:49)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod (IndyInterface.java:232)
at au.com.dius.pact.provider.ProviderVerifier$_finialiseReports_closure32.doCall (ProviderVerifier.groovy:367)
My interaction is
"interactions": [
{
"description": "Consumer interaction of Put Person Algorithm",
"request": {
"method": "PUT",
"path": "model/v0/algorithm/person",
"headers": {
"Authorization": "Bearer ACCESS_TOKEN",
"Content-Type": "application/json"
},
"query": {
"crn": [
"TENANT_NAME"
]
},
"body": {
"standardizers": {},
"encryption": {},
"entity_types": {},
"locale": "en_us"
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
}
},
"providerStates": [
{
"name": "B Put Person Algorithm"
}
]
}
],
If I remove "Content-Type": "application/json" from the request headers, this error will be gone. Is this a bug in the plugin?
Absolutely it supports multiple headers. It may be a big with that specific version or some other artifact of the test process. Could you please file a bug report and ideally a reproducible example?
Worth checking you're on the latest version of the maven plugin also.

what is the data format of axios error info?

when i use console.log(error),it will output
Error: Request failed with status code 400
at myError (myError.js:15)
at settle (settle.js:18)
at XMLHttpRequest.handleLoad (xhr.js:77)
when i use console.log(JSON.stringify(error)),it will output
"response": {
"data": {
"errorList": [
{
"errorCode": "E0100002",
"errorMessage": "没有权限"
}
]
},
"status": 400,
"statusText": "",
"headers": {
"cache-control": "max-age=0",
"content-type": "application/json;charset=UTF-8"
},
"config": {
"transformRequest": {},
"transformResponse": {},
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"headers": {
"Accept": "application/json, text/plain, */*",
"Accept-Language": "zh-CN"
},
"method": "get",
"params": {
"_t": 222,
"_bqq_csrf": "555"
},
"url": "abc.com/*/*/*",
"withCredentials": true,
"promise": {}
},
"request": {
"emonitorAjaxURL": "abc/*/*"
}
}
why the console.log(error) can output the error stack info the console.log(JSON.stringify(error)) does not have.What is actually the data format of the axios error?How much info does the error store that I have not output totally?
Axios augments request-related errors (network errors, timeout errors, and aborts) with several properties, including toJSON(), which customizes how JSON.stringify() formats the resulting string. The string should show several more properties than the one you've shown (I assume you've only copied an excerpt).
The stack trace shown in the console comes from the corresponding Error object.

box.com node client - cannot access files created by collaborator

I'm the co-owner on a box.com file.
My boss is the owner.
I'm using https://www.npmjs.com/package/box-node-sdk to manage the files
The node client has my bosses' enterprise credentials
He made a folder
I made several other sibling folders
I can retreive his
I can't retreive mine
We're both listed as collaborators on all the files
The error I get looks like this:
{
"statusCode": 404,
"response": {
"statusCode": 404,
"body": {
"type": "error",
"status": 404,
"code": "not_found",
"context_info": {
"errors": [
{
"reason": "invalid_parameter",
"name": "item",
"message": "Invalid value 'd_11786923812'. 'item' with value 'd_11786923812' not found"
}
]
},
"help_url": "http://developers.box.com/docs/#errors",
"message": "Not Found",
"request_id": "338009555580a32f872f7c"
},
"headers": {
"server": "ATS",
"date": "Fri, 21 Oct 2016 15:23:36 GMT",
"content-type": "application/json",
"content-length": "324",
"cache-control": "no-cache, no-store",
"strict-transport-security": "max-age=31536000; includeSubDomains",
"vary": "Accept-Encoding",
"age": "0",
"connection": "keep-alive"
},
"request": {
"uri": {
"protocol": "https:",
"slashes": true,
"auth": null,
"host": "api.box.com",
"port": 443,
"hostname": "api.box.com",
"hash": null,
"search": null,
"query": null,
"pathname": "/2.0/folders/11786923812",
"path": "/2.0/folders/11786923812",
"href": "https://api.box.com/2.0/folders/11786923812"
},
"method": "GET",
"headers": {
"User-Agent": "Box Node.js SDK v1.1.0",
"Authorization": "[REMOVED BY SDK]",
"accept": "application/json"
}
}
}
}
EDIT: So, I can get folder 0 and it's not where I'm looking BUT, I did check earlier and added a file where I thought I was looking and it did show up, so I'm guessing that my boss would have to create the files...

Resources