Skip to content

Instantly share code, notes, and snippets.

@TerryFunggg
Created August 31, 2021 09:58
Show Gist options
  • Save TerryFunggg/0b58f094950b0e344ffd32f806442f51 to your computer and use it in GitHub Desktop.
Save TerryFunggg/0b58f094950b0e344ffd32f806442f51 to your computer and use it in GitHub Desktop.
sample of ruby request post api
require 'faker'
require 'net/http'
require 'json'
# static data
def createFakeData()
api_entry = "<Your API Entry>"
# Fake data
areas = ["1", "2", "3","4", "5","6","7","8"]
direciton = "Blue"
area = areas.sample
uri = URI(api_entry)
http = Net::HTTP.new(uri.host, uri.port)
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
req.body = {
YouDate: date
sample_date: Faker::Date.between(from: '2021-06-01', to: '2021-06-30')
}.to_json
res = http.request(req)
puts "#{res.body}"
end
50000.times {|n| createFakeData()}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment