johnwalton 12 Posted September 5, 2018 Report Share Posted September 5, 2018 This is first time configuring API and i've been stuck on this for hours. I get this error; "#postWidgetUpdate: The remote server returned an error: (404) Not Found"It looks like my config is wrong, How do i populate the 'body' field below represented by the -d which is after the 3 preceding 'HTTP Set Headers'. That might do it. Any help would be great here's the code and docs. curl -X POST \ -H "Authorization: Bearer e62a04f681ba57d0120f8f584b688e31f04cf41d" \ -H "Content-Type: application/json" \ -H "Cache-Control: no-cache" \ -d '{"id": "32,35,57"}' \--------------define revcontentAPIUpdateWidgets { set(#revcontentPost1,$plugin function("HTTP post.dll", "$http post", "https://api.revcontent.io/oauth/token", "grant_type=client_credentials&client_id={#revcontentUsername}&client_secret={#revcontentKey}", "", "", "", ""),"Global") set(#token1,$plugin function("JSONpath.dll", "$JSONpath parser", #revcontentPost1, "$..access_token"),"Global") divider plugin command("HTTP post.dll", "http set headers", "Authorization", "Bearer {#token1}") plugin command("HTTP post.dll", "http set headers", "Content-Type", "application/json") plugin command("HTTP post.dll", "http set headers", "Cache-Control", "no-cache") plugin command("HTTP post.dll", "http set headers", "Cache-Control", "no-cache") set(#postWidgetUpdate,$plugin function("HTTP post.dll", "$http post", "https://api.revcontent.io/stats/api/v1.0/boosts/:boost_id/targets/optimizer/widgets/remove", "boost_id=49763", "", "", "", ""),"Global") divider } revcontentAPIUpdateWidgets()}-----------------API Docs:https://api.revcontent.io/docs/stats/#api-Boosts-PostBoostAddSubsection, search for 'remove' Quote Link to post Share on other sites
HelloInsomnia 1103 Posted September 6, 2018 Report Share Posted September 6, 2018 Maybe try this: define revcontentAPIUpdateWidgets { set(#revcontentPost1,$plugin function("HTTP post.dll", "$http post", "https://api.revcontent.io/oauth/token", "grant_type=client_credentials&client_id={#revcontentUsername}&client_secret={#revcontentKey}", "", "", "", ""),"Global") set(#token1,$plugin function("JSONpath.dll", "$JSONpath parser", #revcontentPost1, "$..access_token"),"Global") divider plugin command("HTTP post.dll", "http set headers", "Authorization", "Bearer {#token1}") plugin command("HTTP post.dll", "http set headers", "Content-Type", "application/json") plugin command("HTTP post.dll", "http set headers", "Cache-Control", "no-cache") set(#postWidgetUpdate,$plugin function("HTTP post.dll", "$http post", "https://api.revcontent.io/stats/api/v1.0/boosts/:boost_id/targets/optimizer/widgets/remove", "\{\"boost_id\": \"49763\"\}", "", "", "", ""),"Global") divider } revcontentAPIUpdateWidgets() 1 Quote Link to post Share on other sites
johnwalton 12 Posted September 7, 2018 Author Report Share Posted September 7, 2018 (edited) Hi & thanks for responding, 1.there is one additional piece of data that Must to be passed.It's field ID is 'id' and it's string format is digits separated by commas.How do I include that data into the request?Screenshot of it.https://www.screencast.com/t/SpzvKUVVj 2.The ExBrowser creator mentioned using cURL and Advanced shell which sounds ideal for API calls but i get this error#Post: The screen cannot be set to the number of lines and columns specified3.@HelloInsomniaAre these your sites? (just curious!)http://imautobots.com/https://elitebotters.com/ Edited September 7, 2018 by johnwalton Quote Link to post Share on other sites
johnwalton 12 Posted September 7, 2018 Author Report Share Posted September 7, 2018 Additionally, when i try your code i get this message#postWidgetUpdate: The 'Content-Type' header must be modified using the appropriate property or method.Parameter name: name Quote Link to post Share on other sites
HelloInsomnia 1103 Posted September 12, 2018 Report Share Posted September 12, 2018 Hi & thanks for responding, 1.there is one additional piece of data that Must to be passed.It's field ID is 'id' and it's string format is digits separated by commas.How do I include that data into the request? Screenshot of it.https://www.screencast.com/t/SpzvKUVVj 2.The ExBrowser creator mentioned using cURL and Advanced shell which sounds ideal for API calls but i get this error#Post: The screen cannot be set to the number of lines and columns specified 3.@HelloInsomniaAre these your sites? (just curious!)http://imautobots.com/https://elitebotters.com/ You should be able to add a comma and then another property like so: {"boost_id": "49763","id": "id goes here"} 2. To run curl on Windows I think you have to download it first and then maybe you could call it from shell. But I don't see why you wouldn't just use HTTP Post Plugin. 3. Yes, they are 1 Quote Link to post Share on other sites
HelloInsomnia 1103 Posted September 12, 2018 Report Share Posted September 12, 2018 Additionally, when i try your code i get this message#postWidgetUpdate: The 'Content-Type' header must be modified using the appropriate property or method.Parameter name: name Try this instead: plugin command("HTTP post.dll", "http settings headers", "Content Type", "application/json") 1 Quote Link to post Share on other sites
johnwalton 12 Posted September 14, 2018 Author Report Share Posted September 14, 2018 (edited) Try this instead: plugin command("HTTP post.dll", "http settings headers", "Content Type", "application/json")Your idea here worked on this ^ sub problem. Regarding the primary issue;After adding the 2nd property like so, this 404 error is returned.#1 the API Call URL is correct#2 Authentication is correct#3 The Parameters you helped me form and POST appear to be correct in form. What is my configuration missing or how is it incorrect?PARAM:{"boost_id": "62893","id": "222"}****UBOT Code Below:****define RevContent l POST l Add Widget { Get Bearer() divider plugin command("HTTP post.dll", "http set headers", "Authorization", "Bearer {#bearer}") plugin command("HTTP post.dll", "http settings headers", "Content Type", "application/json") plugin command("HTTP post.dll", "http set headers", "Cache-Control", "no-cache") divider set(#post1,$plugin function("HTTP post.dll", "$http post", "https://api.revcontent.io/stats/api/v1.0/boosts/:boost_id/targets/optimizer/widgets/add", "\{\"boost_id\": \"62893\",\"id\": \"222\"\}", "", "", "", ""),"Global") divider}**** Easy-To-Read API Doc Screenshot:https://www.screencast.com/t/JwDRWrXkoVe Specific Error Returned:#post1: The remote server returned an error: (404) Not Found.Specific Error Returned: Edited September 14, 2018 by johnwalton Quote Link to post Share on other sites
HelloInsomnia 1103 Posted September 14, 2018 Report Share Posted September 14, 2018 The URL you are using isn't right probably because of this part: :boost_id you probably need to use a variable there with the actual boost id. Something like this: set(#post1,$plugin function("HTTP post.dll", "$http post", "https://api.revcontent.io/stats/api/v1.0/boosts/{#boostId}/targets/optimizer/widgets/add", "\{\"boost_id\": \"62893\",\"id\": \"222\"\}", "", "", "", ""),"Global") Also, I don't know if you need the boost id in the parameters now it only shows the id in the photo so maybe try it with and without that one. 1 Quote Link to post Share on other sites
johnwalton 12 Posted September 15, 2018 Author Report Share Posted September 15, 2018 YES it's working! Thanks a lot! 1 Quote Link to post Share on other sites
johnwalton 12 Posted September 15, 2018 Author Report Share Posted September 15, 2018 To end this thread, made a function and command so that the code stays legible in main loop. The naming could be better but i'm still optimizing that to what works best for my eyes and memory lol great to finally have this working, api opens up a new world of speed and efficiency and options. define $RevContent l API URL l Add Widget(#_boostID) { return("https://api.revcontent.io/stats/api/v1.0/boosts/{#_boostID}/targets/optimizer/widgets/add")}comment("Need to turn the widget blacklist listinto a VAR")RevContent l API URL l Add Widget("444,555", 62893)define RevContent l API URL l Add Widget(#_widgetIDs, #_boostID) { comment("This is going to be the API call in command form") divider comment("Settying Header") Check If Blank(#_boostID, "BOOST ID Not Detected") Check If Blank(#_widgetIDs, "WIDGETs Not Detected") Check If Blank(#bearer, "BEARER Not Detected") plugin command("HTTP post.dll", "http set headers", "Authorization", "Bearer {#bearer}") divider plugin command("HTTP post.dll", "http settings headers", "Content Type", "application/json") plugin command("HTTP post.dll", "http set headers", "Cache-Control", "no-cache") divider set(#apiAddWidget,$plugin function("HTTP post.dll", "$http post", $RevContent l API URL l Add Widget(#_boostID), "\{\"id\": \"{#_widgetIDs}\"\}", "", "", "", ""),"Global")} 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.