curl request in ruby RestClient
You can utilize the Restclient::Request.execute. 400 errors typically indicate that the request was not understood by the recipeint. This could be caused by the headers or malformed data. You may need to add the accept header. Try the example below
require 'rest_client'RestClient::Request.execute( method: :post, user: 'api_user@example.com', password: 'pass123', url: "https://example/users.json", headers: {content_type: :json, accept: :json}, payload: { 'user' => { 'name' => 'John Doe', 'email' => 'john.doe@example.com'} }.to_json,)
You can find a detailed list of options here
$url="https://my.fastbill.com/api/1.0/api.php";$curl = curl_init(); curl_setopt($curl,CURLOPT_URL, $url);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);$result = curl_exec($curl);curl_close($curl);print_r(json_decode($result));