curl -X "POST" "https://api.rusic.com/participants" \ -H "Accept: application/vnd.rusic.v1+json" \ -H "X-API-Key: abc123" \ -d "participant[provider]=saml" \ -d "participant[name]=Joe Bloggs " \ -d "participant[nickname]=joebloggs" \ -d "participant[uid]=joebloggs@example.com" \ -d "participant[oauth_token]=xyz"
// Create (POST https://api.rusic.com/participants) $.ajax({ url: "https://api.rusic.com/participants", type: "POST", headers:{ "Accept":"application/vnd.rusic.v1+json", "X-API-Key":"abc123", }, contentType:"application/x-www-form-urlencoded", data:{ "participant[provider]":"saml", "participant[name]":"Joe Bloggs ", "participant[nickname]":"joebloggs", "participant[uid]":"joebloggs@example.com", "participant[oauth_token]":"xyz", }, success:function(data, textStatus, jqXHR){ console.log("HTTP Request Succeeded: " + jqXHR.status); console.log(data); }, error:function(jqXHR, textStatus, errorThrown){ console.log("HTTP Request Failed"); } });
// Create (POST https://api.rusic.com/participants) NSURL* URL = [NSURL URLWithString:@"https://api.rusic.com/participants"]; NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:URL]; request.HTTPMethod = @"POST"; // Headers [request addValue:@"application/vnd.rusic.v1+json" forHTTPHeaderField:@"Accept"]; [request addValue:@"abc123" forHTTPHeaderField:@"X-API-Key"]; // Form URL-Encoded Body NSDictionary* bodyParameters = @{ @"participant[provider]": @"saml", @"participant[name]": @"Joe Bloggs ", @"participant[nickname]": @"joebloggs", @"participant[uid]": @"joebloggs@example.com", @"participant[oauth_token]": @"xyz", }; request.HTTPBody = [NSStringFromQueryParameters(bodyParameters) dataUsingEncoding:NSUTF8StringEncoding]; // Connection NSURLConnection* connection = [NSURLConnection connectionWithRequest:request delegate:nil]; [connection start]; /* * Utils: Add this section before your class implementation */ /** This creates a new query parameters string from the given NSDictionary. For example, if the input is @{@"day":@"Tuesday", @"month":@"January"}, the output string will be @"day=Tuesday&month=January". @param queryParameters The input dictionary. @return The created parameters string. */ static NSString* NSStringFromQueryParameters(NSDictionary* queryParameters) { NSMutableArray* parts = [NSMutableArray array]; [queryParameters enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) { NSString *part = [NSString stringWithFormat: @"%@=%@", [key stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding], [value stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding] ]; [parts addObject:part]; }]; return [parts componentsJoinedByString: @"&"]; } /** Creates a new URL by adding the given query parameters. @param URL The input URL. @param queryParameters The query parameter dictionary to add. @return A new NSURL. */ static NSURL* NSURLByAppendingQueryParameters(NSURL* URL, NSDictionary* queryParameters) { NSString* URLString = [NSString stringWithFormat:@"%@?%@", [URL absoluteString], NSStringFromQueryParameters(queryParameters), ]; return [NSURL URLWithString:URLString]; }
require 'net/http' def send_request # Create (POST ) begin uri = URI('https://api.rusic.com/participants') # Create client http = Net::HTTP.new(uri.host, uri.port) data = { "participant[provider]" => "saml", "participant[name]" => "Joe Bloggs ", "participant[nickname]" => "joebloggs", "participant[uid]" => "joebloggs@example.com", "participant[oauth_token]" => "xyz", } body = URI.encode_www_form(data) # Create Request req = Net::HTTP::Post.new(uri) # Add headers req.add_field "Accept", "application/vnd.rusic.v1+json" # Add headers req.add_field "X-API-Key", "abc123" # Set header and body req.body = body # Fetch Request res = http.request(req) puts "Response HTTP Status Code: #{res.code}" puts "Response HTTP Response Body: #{res.body}" rescue Exception => e puts "HTTP Request failed (#{e.message})" end end
Body Params
participant
object
Response

Language
Credentials
Choose an example:
text/plain