Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help with headers and --data-binary? #27

Closed
vjcitn opened this issue Feb 15, 2021 · 1 comment
Closed

help with headers and --data-binary? #27

vjcitn opened this issue Feb 15, 2021 · 1 comment

Comments

@vjcitn
Copy link

vjcitn commented Feb 15, 2021

Wonderful package. Can you give some guidance on how to present a query with headers as given in this curl excerpt

-H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: https://pharos-api.ncats.io' --data-binary

It isn't at all clear to me how to pass the --data-binary element.

I wrote the headers as

hlist =  list(
`Accept-Encoding`=c("gzip", "deflate", "br"),
`Content-Type`="application/json",
`Accept`="application/json",
`Connection`="keep-alive",
`DNT`="1",
`Origin`="https://pharos-api.ncats.io/graphql")

but server returns 500 on

library(ghql)
hlist =  list(
`Accept-Encoding`=c("gzip", "deflate", "br"),
`Content-Type`="application/json",
`Accept`="application/json",
`Connection`="keep-alive",
`DNT`="1",
`Origin`="https://pharos-api.ncats.io/graphql")


con = GraphqlClient$new(url="https://pharos-api.ncats.io/graphql", headers=hlist)

con$load_schema(schema_file="pharos_introspectionSchema.json")

qry = Query$new()

qry$query('myd', '{
interactingProteins{
  targets(filter: { associatedTarget: "PPBP" }) {
    targets(top:5) {
      name
      sym
      ppiTargetInteractionDetails {
        dataSources:ppitypes
        score
        interaction_type
        evidence
        p_ni
        p_int
        p_wrong
      }
    }
  }
}
}')

qry
xx = con$exec(qry$queries$myd)
@sckott
Copy link
Contributor

sckott commented Feb 19, 2021

So you have successfully made a curl request on the command line/shell with that command above?

You shouldn't need to pass --data-binary.

Your accept encoding header should be a string, all headers should be strings of length 1., should be "deflate, gzip, br"

After you fix that header, now I get a 400 error. If I try your query in the https://pharos-api.ncats.io/graphql gui it does not work. So it seems your query is not valid as well

@mpadge mpadge closed this as completed Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants