Giter Club home page Giter Club logo

Comments (6)

rahul0x24 avatar rahul0x24 commented on May 27, 2024

@Gargo, Thanks for reaching out. Could you please print the curl for the command by using the following code -

let service = FDGetPlayerSummariesService(steamids: ["76561198015933145"])
print(service.request.debugDescription)

from restofire.

rahul0x24 avatar rahul0x24 commented on May 27, 2024

I could see the following response from the server after running the curl of the service you gave me.

curl -v \
>       -H "User-Agent: Restofire/1.0 (com.apple.dt.playground.stub.iOS_Simulator.Restofire-1A30C476-4FA9-48B7-B61B-451B5DCF5FC2; build:1; iOS 13.3.0) Alamofire/4.9.1" \
>       -H "Accept-Language: en;q=1.0" \
>       -H "Content-Type: application/json" \
>       -H "Accept-Encoding: gzip;q=1.0, compress;q=0.5" \
>       -d "{}" \
>       "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?steamids=76561198015933145&key=BBD52AB62CD9B4E067C060466F0E9AC9"
*   Trying 104.103.200.178...
* TCP_NODELAY set
* Connected to api.steampowered.com (104.103.200.178) port 80 (#0)
> POST /ISteamUser/GetPlayerSummaries/v0002/?steamids=76561198015933145&key=BBD52AB62CD9B4E067C060466F0E9AC9 HTTP/1.1
> Host: api.steampowered.com
> Accept: */*
> User-Agent: Restofire/1.0 (com.apple.dt.playground.stub.iOS_Simulator.Restofire-1A30C476-4FA9-48B7-B61B-451B5DCF5FC2; build:1; iOS 13.3.0) Alamofire/4.9.1
> Accept-Language: en;q=1.0
> Content-Type: application/json
> Accept-Encoding: gzip;q=1.0, compress;q=0.5
> Content-Length: 2
>
* upload completely sent off: 2 out of 2 bytes
< HTTP/1.1 405 Method Not Allowed
< Allow: GET
< Content-Length: 146
< Content-Type: text/html; charset=UTF-8
< Expires: Tue, 07 Jan 2020 23:13:09 GMT
< Cache-Control: max-age=0, no-cache, no-store
< Pragma: no-cache
< Date: Tue, 07 Jan 2020 23:13:09 GMT
< Connection: close
<
* Closing connection 0
<html><head><title>Method Not Allowed</title></head><body><h1>Method Not Allowed</h1>This API must be called with a HTTP GET request</body></html>%

Since it is a get request and you are adding parameters, You might want to change to queryParameters. Try replacing your service code with the following code

struct FDGetPlayerSummariesService: Requestable {
    typealias Response = FSUserInfoModel
    var path: String? = "ISteamUser/GetPlayerSummaries/v0002/?steamids=76561198015933145&key=BBD52AB62CD9B4E067C060466F0E9AC9"
    var queryParameters: [String: Any]?

    init(steamids: [String]) {
//        let steamidsString = steamids.joined(separator: ",")
//        queryParameters = ["steamids": steamidsString, "key": apiKey]
        queryParameters = [:]
    }

    func request(_ request: RequestOperation<FDGetPlayerSummariesService>, didCompleteWithValue value: [FSUserInfoModel]) {
        print()
    }

    func request(_ request: RequestOperation<Self>, didFailWithError error: Error) {
        print()
    }
}

from restofire.

gerchicov-bp avatar gerchicov-bp commented on May 27, 2024

@RahulKatariya thanks now it works at least with a hardcoded path. But you should mention the whole _Configurable protocol in readme.

from restofire.

rahul0x24 avatar rahul0x24 commented on May 27, 2024

@gerchicov-bp. I admit more documentation or examples are indeed required to understand fully. I couldn't help but notice your comment, there is a dictionary extension that takes care of adding nil with a dictionary. Are you still not able to use it with parameters?

from restofire.

Gargo avatar Gargo commented on May 27, 2024

@gerchicov-bp everything seems to be ok now. Previously I didn't see that parameters and queryParameters have different types.

from restofire.

rahul0x24 avatar rahul0x24 commented on May 27, 2024

I am glad it all worked out for you. Closing the issue then!

from restofire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.