Closed ghamkhari closed 7 years ago
"No primary access chain found" means that you do not have permission to work with that URI. Who created "building.city"? You need to grant a DOT to the entity you are using (what you've pointed to with BW2_DEFAULT_ENTITY
) before you can interact with that URI.
You can check the existence of that DOT using the bw2 buildchain
command:
bw2 bc -t <your entity file or VK here> -u 'building.city/mydrivers/s.weatherunderground/Berkeley/!meta/state'
The variable BW2_DEFAULT_ENTITY
points to mahdi.net
, but building.city
is created by ns.net
. Issue was resolved after ns.net
gave permissions to mahdi.net
:
bw2 mkdot --from ns.net --to mahdi.net --uri "building.city/mydrivers/*" --ttl 5 --permissions "PC*"
@ghamkhari for specific questions like these, its better to just send me an email
@gtfierro I will ask next questions in Emails.
I am running the Example in this page.
The only parts I have modified:
1- Instead of
scratch.ns
I usebuilding.city
2- In linestate_uri := service.FullURI() + "Berkeley/!meta/state"
I changeBerkeley
to/Berkeley
Running the code results in:
1511259537853502741 [Info] Connected to BOSSWAVE router version 2.7.6 'Klystron'
Could not publish: [401] No primary access chain found, cannot elaborate
exit status 1
The code is shown below:
package main
import (
bw2 "gopkg.in/immesys/bw2bind.v5"
"os"
"time"
)
func main() {
client := bw2.ConnectOrExit("")
client.OverrideAutoChainTo(true)
client.SetEntityFileOrExit(os.Getenv("BW2_DEFAULT_ENTITY"))
baseuri := "building.city/mydrivers"
service := client.RegisterService(baseuri, "s.weatherunderground")
service.SetMetadata("type", "Web Service")
service.SetMetadata("url", "https://www.wunderground.com/weather/api/")
po := bw2.CreateMetadataPayloadObject(&bw2.MetadataTuple{
Value: "California",
Timestamp: time.Now().UnixNano(),
})
state_uri := service.FullURI() + "/Berkeley/!meta/state"
client.PublishOrExit(&bw2.PublishParams{
PayloadObjects: []bw2.PayloadObject{po},
URI: state_uri,
Persist: true,
})
}