#StackBounty: #ruby-on-rails #ruby #web-services #httpclient #httparty Send multiple files using HTTParty

Bounty: 50

Here is the code which is working using Net::HTTP::Post

request = Net::HTTP::Post.new(url)
...
form_data = [
  ['attachments[]', File.open('file1.txt')],
  ['attachments[]', File.open('file2.txt')]
]
request.set_form form_data, 'multipart/form-data'
http.request(request)

Now, I am trying to use httparty like below but it is not working.

body = { attachments: [ File.open('file1.txt'), File.open('file2.txt') ] }

HTTParty.post(url, body: body)

The response I am getting from web service call is below:

#<HTTParty::Response:0x557d7b549f90 parsed_response={"error"=>true, "error_code"=>"invalid_attachment", "error_message"=>"Attachmen
t(s) not found or invalid."}, @response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>, @headers={"server"=>["nginx"], "date"=>[
"Mon, 20 May 2019 07:41:50 GMT"], "content-type"=>["application/json"], "content-length"=>["102"], "connection"=>["close"], "vary"=>["
Authorization"], "set-cookie"=>["c18664e1c22ce71c0c91742fbeaaa863=uv425hihrbdatsql1udrlbs9as; path=/"], "expires"=>["Thu, 19 Nov 1981
08:52:00 GMT", "-1"], "cache-control"=>["no-store, no-cache, must-revalidate", "private, must-revalidate"], "pragma"=>["no-cache", "no
-cache"], "x-ratelimit-limit"=>["60"], "x-ratelimit-remaining"=>["59"], "strict-transport-security"=>["max-age=63072000; includeSubdom
ains;"]}>

It looks like it is not able to read the contents of files. Does HTTParty supports this or I need to use some other gem?


Get this bounty!!!

#StackBounty: #xamarin.forms #httpclient #client-certificates Using / Accepting Self Signed Certificate in Xamarin Forms Application

Bounty: 100

enter image description here

In my Xamarin Forms(iOS & Android) Application I am using Azure API app for consuming the API’s. Previously I was using Bareer Token only for authorisation. And recently the team handling services implemented Client Certificate as an additional security measure. But I am not sure how I can achieve the same in Xamarin Forms.

I am using .Net HttpClient for consuming the API’s.

I have found several people asking the same question in the stackoverflow and Xamarin forums. But I haven’t get a solution for Xamarin Forms that can be used for both iOS and Android.

I do find people advising to implement this specific to Platform; But there also I can’t find any method to use it along with my current HttpClient implementation.


Get this bounty!!!