HTTP API problems


(RUI SUN) #1

When i try to use the HTTP API to query data from Stardog , the response is that " 400 Bad Request
{“message”:"No separator character found in the URI: "} ". I request Stardog server by Golang programming language. That problem also appeared by CURL way.

Code:

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	client := &http.Client{}

	body := []byte("query=SELECT ?x { ?x ?p ?o }")

	req, _ := http.NewRequest("GET", "http://0.0.0.0:5820/pizza/query?query=&baseURI=&limit=&offset=&timeout=", bytes.NewBuffer(body))

	req.Header.Add("Accept", "text/turtle, application/rdf+xml, application/n-triples, application/trig, application/n-quads, text/n3, application/trix, application/ld+json, application/sparql-results+xml, application/sparql-results+json, application/x-binary-rdf-results-table, text/boolean, text/csv, text/tsv, text/tab-separated-values")

	resp, err := client.Do(req)

	if err != nil {
		fmt.Println("Errored when sending request to the server")
		return
	}

	defer resp.Body.Close()
	resp_body, _ := ioutil.ReadAll(resp.Body)

	fmt.Println(resp.Status)
	fmt.Println(string(resp_body))
}

(zachary.whitley) #2

Maybe http/net already does it for you but you might need to percent encode your query.


(system) #3

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.