I have a problem setting up a RESTAPI call in Azure Data Factory - rest

I am trying to create a POST to an REST-API but I get this output (Caught by an Logic Apps HTTP grab):
{
"headers": {
! "Connection": "Keep-Alive",
"Accept": "application/json",
"Accept-Encoding": "gzip,deflate",
! "Host": "prod-187.westeurope.logic.azure.com:443",
"User-Agent": "azure-data-factory/2.0",
"Content-Length": "55",
! "Content-Type": "application/json",
"Content-Encoding": "UTF-8"
},
"body": {
"$content-encoding": "UTF-8",
"$content-type": "application/json",
"$content": "eyJuYW1lIjoiSmVzcGVyIEIuIEhhbnNlbiIsInNhbGFyeSI6IjEyMzQ1IiwiYWdlIjoiMzQifQ=="
}
}
I would have expected this:
{
"headers": {
"Accept": "application/json",
"Accept-Encoding": "deflate,gzip",
"Host": "prod-187.westeurope.logic.azure.com",
"User-Agent": "Mozilla/5.0,(Windows NT 10.0; Win64; x64),AppleWebKit/537.36,(KHTML, like Gecko),Chrome/103.0.5060.134,Safari/537.36,Edg/103.0.1264.71",
"X-Real-IP": "212.237.135.241",
"Content-Length": "42",
"Content-Type": "application/json"
},
"body": {
"name": "Jesper B. Hansen",
"salary": "12345",
"age": "34"
}
}
Why is the output scrambled?
I tried using a REST Service on a sink, and also tried it with an externalCall no real difference...
I must say, I am new at ADF, but I hope you have some good help for me.

Related

trying to fetch data with invokerestmethod and curl

hello there im trying to convert the following curl command to a powershell solution
curl -X GET "https://api.cloudflare.com/client/v4/radar/ranking/top?limit=100&name=main_series&location=US&date=$(date +'%Y-%m-%d)&format=json" \
-H "Authorization: Bearer VqMBNIOyImZ_W-T4HIYOq93vnuWozOrNSR4NcsNA" \-H "Content-Type: application/json";
So im running the following command
$request = Invoke-RestMethod -Method Get -Uri "https://api.cloudflare.com/client/v4/radar/ranking/top?limit=100&name=main_series&location=US&date=$('date +%Y-%m-%d')&format=json&Authorization: Bearer VqMBNIOyImZ_W-T4HIYOq93vnuWozOrNSR4NcsNA&Content-Type:application/json"
So i need assistance this is my first time doing this because im not getting any response back and i would like to get a response
Here is a side by side example using httpbin, which is something you should use in your testing before you give people on SO your credentials to a private API. Hopefully this shows how you can use powershell for your needs.
running:
curl -X GET "https://httpbin.org/get?limit=100&name=main_series\
&location=US&date=$( date +%Y-%m-%d)&format=json" \
-H "Authorization: Bearer sample" -H "Content-Type: application/json"
returns
{
"args": {
"date": "2022-10-19",
"format": "json",
"limit": "100",
"location": "US",
"name": "main_series"
},
"headers": {
"Accept": "*/*",
"Authorization": "Bearer sample",
"Content-Type": "application/json",
"Host": "httpbin.org",
"User-Agent": "curl/7.85.0",
"X-Amzn-Trace-Id": "Root=*REDACTED*"
},
"origin": "*REDACTED*",
"url": "https://httpbin.org/get?limit=100&name=main_series&location=US&date=2022-10-19&format=json"
}
running
$headers = #{}
$headers.Add("Content-Type", "application/json")
$headers.Add("Authorization", "Bearer sample")
$time = (Get-Date).ToString("yyyy-MM-dd")
$request = Invoke-RestMethod -Method Get -Uri "https://httpbin.org/get?limit=100&name=main_series&location=US&format=json&date=$($time)" -Headers $headers
$request | ConvertTo-Json
returns
{
"args": {
"format": "json",
"limit": "100",
"location": "US",
"name": "main_series",
"date": "2022-10-19"
},
"headers": {
"Authorization": "Bearer sample",
"Content-Type": "application/json",
"Host": "httpbin.org",
"User-Agent": "Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.19041.1682",
"X-Amzn-Trace-Id": "Root=*REDACTED*"
},
"origin": "*REDACTED*",
"url": "https://httpbin.org/get?limit=100\u0026name=main_series\u0026location=US\u0026format=json\u0026time=2022-10-19"
}

Flutter Dio NO_RENEGOTIATION(ssl_lib.cc:1725) error 268435638

I have a problem when I make a http request to the server
when I post on flutter it returns NO_RENEGOTIATION(ssl_lib.cc:1725) error 268435638 error, but when I try to use postman it works fine.
I've equated all the headers with postman, replaced Jcenter() with MavenCentral() and it doesn't work
This is the code I use:
final Map<String, dynamic> requestData = {
"email": Encryption().encryptKey(email),
"password": Encryption().encryptKey(password),
"user_ad": userType,
"token_fcm": _tokenFcm,
"is_encrypted": true,
};
Response response = await _dio.post(
"$basePath/login",
data: FormData.fromMap(requestData),
options: Options(
headers: {
"Connection": "keep-alive",
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Host": "btnsmartdev.btn.co.id",
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Content-Length": "173"
},
validateStatus: (status) {
print("INI STATUS");
print(status);
return (status ?? 0) < 500;
},
followRedirects: false,
)
);
final data = response.data;
Here's what I get in terminal:
Here's the request from postman:

How to send sms to user using msg91 in flutter?

I have written the api call like this:
var response = await http.post(
Uri.parse("http://api.msg91.com/api/v2/sendsms"),
headers: {
"Content-Type": "application/json",
"authkey": "API key"
},
body: jsonEncode({
"sender": "note",
"route": "4",
"country": "91",
"flash": 1,
"sms":
{"message": "Message1", "to": "9999999999"}
}),
);
But this giving me error : {type: error, message: Invalid content type.Please send data in formdata,application/xml,application/json format, code: }
How can I correct this?
Try removing theses
"Content-Type": "application/json"
or replace it with
"Content-Type": "application/xml"
You should use multipart/form-data as content-type ->
"Content-Type": "multipart/form-data"

Google Apps Script doesn't recognize "Host" header in HTTP POST request?

I'm trying to query ArcGIS Rest API from Google Apps script. Building the request in Postman works perfectly fine, but when I get the code into apps script, I'm having trouble that I cant seem to figure out. Here's the code:
function callEsri () {
var url = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0/query"
var params =
{
"async": true,
"crossDomain": true,
"url": "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0/query",
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "PostmanRuntime/7.20.1",
"Accept": "*/*",
"Cache-Control": "no-cache",
"Postman-Token": "[TOKEN]",
"Host": "services3.arcgis.com",
"Accept-Encoding": "gzip, deflate",
"Content-Length": "125",
"Connection": "keep-alive",
"cache-control": "no-cache"
},
"data": {
"f": "json",
"where": "CITY_JUR LIKE '%Los Angeles%'",
"outSr": "4326",
"outFields": "TRL_NAME,ELEV_FT,CITY_JUR,PARK_NAME,FID"
}
}
var response = UrlFetchApp.fetch(url, params);
var json = response.getContentText();
var data = JSON.parse(json);
Logger.log(data);
}
The Error I am getting is: Execution failed: Attribute provided with invalid value: Header:Host (line 28, file "Code")
Any reason why Google is not recognizing this and is there a way to fix this? Any help/advice is greatly appreciated.
As #TheMaster has already noted in the comments. You are already specifying the Host in the url.
Also you can take a look at the official documentation of URLFetchApp.
And in case you want more information in the head here you have the mozilla documentation on that header and also the RFC specifying the Host header.

Getting invalid_payment response from uber with 400 status code;using rest API

I am using REST API to book and uber ride using: https://api.uber.com/v1.2/requests .
It's not working with payment methods other than Cash.
I am getting 400 with code:invalid_payment
Can someone please help me out;
I am able to make payment using cash & Paytm for Indian locations.
I am not able to make payment using cash for US locations.
I am not able to make payment using the card for Indian & US locations.
When I add a new card via the Uber app and try to book a cab in the uber using the card it works; When I try to use the same card using my app it shows error. After this when I try to book a cab using the uber app; it doesn't work.
This the the response I am getting from Uber:
{
"data": {
"meta": {},
"errors": [
{
"status": 400,
"code": "invalid_payment",
"title": "The rider's payment method is invalid and they must update their billing info."
}
]
},
"status": 400,
"headers": {
"server": "nginx",
"strict-transport-security": "max-age=604800",
"x-frame-options": "SAMEORIGIN",
"content-type": "application/json",
"content-geo-system": "wgs-84",
"date": "Fri, 05 Apr 2019 06:28:50 GMT",
"x-content-type-options": "nosniff",
"content-length": "151",
"cache-control": "max-age=0",
"connection": "keep-alive",
"x-xss-protection": "1; mode=block"
},
"config": {
"transformRequest": {},
"transformResponse": {},
"timeout": 180000,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"headers": {
"Accept": "application/json, text/plain, /*",
"Content-Type": "application/json",
"authorization": "Bearer JA.ZWU",
"Accept-Language": "en_US"
},
"method": "post",
"url": "https://api.uber.com/v1.2/requests",
"data": "{\"start_latitude\":40.8037381,\"start_longitude\":-73.9577813,\"end_latitude\":40.68780810000001,\"end_longitude\":-73.8057292,\"fare_id\":\"7636a3afa24d7648656aabbcc695bf094d4eed6d9323f3b10a5a5868a47c\",\"product_id\":\"b64-5de2-4539-a35a-986d6e58f186\",\"payment_method_id\":\"0xxxx-90ce-4c1d-a8c4-af7b1a00c3cf\"}"
},
"request": {
"UNSENT": 0,
"OPENED": 1,
"HEADERS_RECEIVED": 2,
"LOADING": 3,
"DONE": 4,
"readyState": 4,
"status": 400,
"timeout": 180000,
"withCredentials": true,
"upload": {},
"_aborted": false,
"_hasError": false,
"_method": "POST",
"_response": "{\"meta\":{},\"errors\":[{\"status\":400,\"code\":\"invalid_payment\",\"title\":\"The rider's payment method is invalid and they must update their billing info.\"}]}",
"_url": "https://api.uber.com/v1.2/requests",
"_timedOut": false,
"_trackingName": "unknown",
"_incrementalEvents": false,
"responseHeaders": {
"Server": "nginx",
"Strict-Transport-Security": "max-age=604800",
"X-Frame-Options": "SAMEORIGIN",
"Content-Type": "application/json",
"Content-Geo-System": "wgs-84",
"Date": "Fri, 05 Apr 2019 06:28:50 GMT",
"X-Content-Type-Options": "nosniff",
"Content-Length": "151",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"X-XSS-Protection": "1; mode=block"
},
"_requestId": null,
"_headers": {
"accept": "application/json, text/plain, /*",
"content-type": "application/json",
"authorization": "Bearer JA.VUNU",
"accept-language": "en_US"
},
"_responseType": "",
"_sent": true,
"_lowerCaseResponseHeaders": {
"server": "nginx",
"strict-transport-security": "max-age=604800",
"x-frame-options": "SAMEORIGIN",
"content-type": "application/json",
"content-geo-system": "wgs-84",
"date": "Fri, 05 Apr 2019 06:28:50 GMT",
"x-content-type-options": "nosniff",
"content-length": "151",
"cache-control": "max-age=0",
"connection": "keep-alive",
"x-xss-protection": "1; mode=block"
},
"_subscriptions": [],
"responseURL": "https://api.uber.com/v1.2/requests"
}
}
Actual result should be ride request accepted.