Giter Club home page Giter Club logo

Comments (3)

adam-fowler avatar adam-fowler commented on May 12, 2024

Had a little investigation here. Your body is as follows

Action=CreatePlatformApplication
&Name=myapp
&Platform=APNS_SANDBOX
&Attributes.PlatformCredential=<private key>
&Attributes.PlatformPrincipal=<ssl certificate>
&Version=2010-03-31

AWS is expecting it in the following form

Action=CreatePlatformApplication
&Name=myapp
&Platform=APNS_SANDBOX
&Attributes.entry.1.key=PlatformCredential 
&Attributes.entry.1.value=<private key>
&Attributes.entry.2.key=PlatformPrincipal
&Attributes.entry.2.value=<ssl certificate>
&Version=2010-03-31

It appears to be serializeToFlatDictionary() that is returning the "malformed" dictionary.

from soto.

adam-fowler avatar adam-fowler commented on May 12, 2024

I fixed the code to output the correct dictionary format in JSONSerializer.serializeToFlatDictionary(). See code changes below

    func serializeToFlatDictionary(_ data: Data) throws -> [String: Any] {
        func flatten(dictionary: [String: Any]) -> [String: Any] {
            var flatted: [String: Any] = [:]

            func destructiveFlatten(dictionary: [String: Any]) {
                for (key, value) in dictionary {
                    switch value {
                    case let value as [String: Any]:
                        for iterator in flatten(dictionary: value).enumerated() {
                            switch iterator.element.value {
                            case let value2 as [String: Any]:
                                destructiveFlatten(dictionary: value2)

                            case let values as [Any]: // TODO: values<Element> might be dictionary...
                                for iterator in values.enumerated() {
                                    flatted["\(key).member.\(iterator.offset+1)"] = iterator.element
                                }

                            default:
                                flatted["\(key).entry.\(iterator.offset+1).key"] = iterator.element.key
                                flatted["\(key).entry.\(iterator.offset+1).value"] = iterator.element.value
                            }
                        }
                        
                    case let values as [Any]: // TODO: values<Element> might be dictionary...
                        for iterator in values.enumerated() {
                            flatted["\(key).member.\(iterator.offset+1)"] = iterator.element
                        }

                    default:
                        flatted[key] = value
                    }
                }
            }
            destructiveFlatten(dictionary: dictionary)
            return flatted
        }

CreatePlatformApplication is still failing though. It is now returning the error "PlatformPrincipal not valid". I have tested the certificate and key using the CLI and web interface and they both work fine.

from soto.

adam-fowler avatar adam-fowler commented on May 12, 2024

Closing this issue in favour of splitting it into two #106 and #107

from soto.

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.