public async Task CriarCollection(PostmanCollection collection) { var content = JsonConvert.SerializeObject(collection, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var responseString = await "https://api.getpostman.com/collections" .WithHeader("X-Api-Key", "88d96b1dbe8946ecaecee62807879e86") .PostStringAsync(content) .ReceiveString(); }
public async Task CriarOuAtualizarCollection(PostmanCollection collection) { var collectionExistente = await BuscarCollectionPorNome(collection.collection.info.name); if (collectionExistente != null) { await AtualizarCollection(collection); } else { await CriarCollection(collection); } }
public async Task AtualizarCollection(PostmanCollection collection) { var collections = await BuscarCollections(); var collectionInfo = collections.collections.SingleOrDefault(x => x.name == collection.collection.info.name); var content = JsonConvert.SerializeObject(collection, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var responseString = await $"https://api.getpostman.com/collections/{collectionInfo.uid}" .WithHeader("X-Api-Key", "88d96b1dbe8946ecaecee62807879e86") .PutStringAsync(content) .ReceiveString(); }