Created
August 31, 2021 09:58
-
-
Save TerryFunggg/0b58f094950b0e344ffd32f806442f51 to your computer and use it in GitHub Desktop.
sample of ruby request post api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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