简体   繁体   English

通过邮递员进行多个PUT请求?

[英]Multiple PUT requests via Postman?

We had an issue with our Shopify store where we lost all our product images somehow. 我们的Shopify商店出现问题,我们不知何故丢失了所有产品图片。 Well, the images are still in their cloud, but have become disassociated from the products themselves. 好吧,这些图像仍然在它们的云中,但是已经与产品本身分离了。

Long story short, the images could not be reassociated by Shopify support, so I created a bunch (thousands) of PUT requests to update the products with the appropriate product images. 长话短说,Shopify支持无法将图像重新关联,因此我创建了成千上万个PUT请求,以使用适当的产品图像更新产品。

I am using Postman, but from what I can tell, there's not a quick way to send the PUT commands, headers and JSON string all at once to make the update for each of the several thousand images. 我正在使用Postman,但据我所知,没有一种快速的方法可以一次发送PUT命令,标头和JSON字符串来对数千个图像中的每一个进行更新。

My formatted strings are as such: 我格式化的字符串是这样的:

Request: 请求:

PUT [store name]/admin/api/2019-04/products/[product id].json PUT [商店名称] / admin / api / 2019-04 / products / [product id] .json

Headers: 头:

Host: [store url] Content-Type: application/json Authorization: Basic [api key] cache-control: no-cache 主机:[store url]内容类型:application / json授权:基本的[api键]缓存控制:无缓存

JSON: JSON:

 {'product': {'id': [the id],'images': [{'src': '[image url already in shopify]'}]}} 

Is there a way in Postman to run all these calls at once, or if not through Postman, some other program? Postman中有一种方法可以一次运行所有这些调用,或者如果不是通过Postman,可以运行其他程序? We don't have cURL here at my work so installing that is not an option. 我们的工作中没有cURL,因此无法安装。

I did see there are bulk edit commands in Postman, but it appears I'd have to enter each part manually, so for thousands of calls, this isn't a viable option. 我确实看到Postman中有批量编辑命令,但是看来我必须手动输入每个部分,因此对于成千上万的电话来说,这不是一个可行的选择。 I have a feeling the answer is I'd have to write an app to do this, which I can do, but since I have all these formatted strings already I thought there might be a way to make use of what I have now. 我的答案是我必须编写一个应用程序来做到这一点,而我可以做到,但是由于我已经拥有了所有这些格式化的字符串,所以我认为可能有一种利用我现在拥有的方法的方法。

Assuming that you do have the data in a CSV file you could use Postman's Collection Runner with a data file and data variables. 假设您确实将数据保存在CSV文件中,则可以将Postman的Collection Runner与数据文件和数据变量一起使用。 Here's a blog post that explains it pretty well: 这是一篇博客文章,很好地解释了它:

https://blog.getpostman.com/2018/04/11/looping-through-a-data-file-in-the-postman-collection-runner/ https://blog.getpostman.com/2018/04/11/looping-through-a-data-file-in-the-postman-collection-runner/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM