```package main import ( "context" "fmt" ory ...
# ory-network
b
Copy code
package main

import (
	"context"
	"fmt"

	ory "<http://github.com/ory/client-go|github.com/ory/client-go>"
)

var client = NewSDK()

// Use this context to access Ory APIs which require an Ory API key.
var oryAuthedContext = context.WithValue(context.Background(), ory.ContextAccessToken, "ory_pat_vvvvvvv")

func NewSDK() *ory.APIClient {
	conf := ory.NewConfiguration()
	conf.Servers = ory.ServerConfigurations{{
		URL: "<https://vvvvvvv.projects.oryapis.com/>",
	}}

	return ory.NewAPIClient(conf)
}

func main() {
	identity, res, err := client.IdentityApi.CreateIdentity(oryAuthedContext).CreateIdentityBody(ory.CreateIdentityBody{
		SchemaId: "default",
		Traits: map[string]interface{}{
			"email": "<mailto:hello@example.org|hello@example.org>",
		},
	}).Execute()
	if err != nil {
		panic(err)
	}

	fmt.Println(identity.Id, res.StatusCode)

}
p
Hi @bright-policeman-41717 You need to get your projects default identity schema ID. It won't be "default"
You can get the default identity schema by running the CLI
Copy code
$ ory list projects
$ ory get project <id> --format json | jq | grep default_schema_id
w
BTW @bright-policeman-41717, please post codeblocks in a single thread not as separate messages. It’ll help the ppl that try to help you get a better overview of the problems you’re facing. Additionally, it’ll make it easier to browse the channels and get to messages from other Ory users. It’s cumbersome to scroll through multiple codeblocks to find messages of other community members that might need help or advice. Thanks! 🙂
🙌 1
b
Copy code
identity, res, err := client.IdentityApi.CreateIdentity(oryAuthedContext).CreateIdentityBody(ory.CreateIdentityBody{
        SchemaId: "<preset://email>",
        Traits: map[string]interface{}{
            "email": "<mailto:vvvvv@gmail.com|vvvvv@gmail.com>",
        },
    }).Execute()
    if err != nil {
        log.Println(err.Error())
    }
added the scema id as well still the error persists
a
you may try without setting schemaId. it worked for me.
p
I think the URL is incorrect
I just tried this on my side and it worked fine
Copy code
func NewSDK() *ory.APIClient {
	conf := ory.NewConfiguration()
	conf.Servers = ory.ServerConfigurations{{
		URL: "https://.<http://projects.oryapis.com|projects.oryapis.com>", <-- removed /
	}}

	return ory.NewAPIClient(conf)
}
b
Yes url had a trailing / , mistake is on me , sorry for the mess