Hello i'm trying to use the Web API for rF2. The one you find here after launching rF2 : http://localhost:5397/swagger/index.html I'm using the ai/add call to try and add an AI from a powershell. Here is the API working well with "Try it out" : And here is a powershell script that should do the same, but don't work (Not the right car added) : Code: $url = "http://localhost:5397/rest/sessions/ai/add" $body = @{ "String" = "BMW M8 GTE #22" } Invoke-RestMethod -Method 'Post' -Uri $url -Body ($body|ConvertTo-Json) -ContentType "application/json" Anyone know how this API should be scripted in Powershell and can help me ? Thanks.
Yes, launch the game and get to http://localhost:5397/swagger/index.html url in your favorite browser. It is a "standard" API rest so it should work like any other Rest API.
Thanks. I'm always learning new things. It looks like the parameter type is the important info. The first column "Parameter" isn't really used. I would try with: Code: $body = "BMW M8 GTE #22" You can open the Network tab in the browser developer tools to see how petitions are sent.
Thanks, i will try that. If it works on the dedicated server too, it would be a solution to setup a race with selected AIs, which is actually not possible without repackaging rfcmps and keeping exclusively skins used.
Hello, i have managed to use javascript and try the REST API to add AIs via an html page. It works perfectly on single player but doesn't seem to work on a dedicated ... Why ! Somebody here can confirm (or not) that the Rest API is only available in single player mode ? Thanks. PS : The url http://localhost:5397/swagger/index.html#!/sessions/addAi works on a dedicated but nothing happens when i use the "Try out" on ai/add api ... It definitely looks like the rest Api is really unavailable on a dedicated.
Im also a bit interested in the Rest API. Is there a way 'to talk' to the pit menu through the rest api available in Rfactor2? Im trying to find a little more effecient way to change fuel, tyres, other settings by setting up some buttons (set primary, set alternate, set fuel to finish, ...) on the matric app (Software buttonbox, which supports HTTP requests). Also possibility to read fuel info from car? I went trough this http://localhost:5397/swagger/index.html but couldnt find something. This documentation was foundable in one of the JAR files of rfactor2
Crew Chief will do all that (and more) with voice commands and you can bind them to buttons if you want to.
I had a poke around, I didn't find anything outstandingly useful and sometimes useless: http://localhost:5397/swagger/index.html#!/race/getVehicleDescription Code: Response Body { "poContent": "This vehicle has a F2 0.75L engine and is manufactured by Dubouis Bonheur." } for the GT3 McLaren! I did find another URL that did give correct (if limited) data about the car but I can't find it again. Maybe the API is designed for automatic testing of the UI?