func checkGetRelativeURL(relativeURI string, ctxURL string) string {
	if string([]rune(relativeURI)[0]) != "/" {
		absoluteURL := getPriorEndpoint(ctxURL, "/_api")
		relativeURL := getRelativeURL(absoluteURL)
		relativeURI = fmt.Sprintf("%s/%s", relativeURL, relativeURI)
	}
	return relativeURI
}
checkGetRelativeURL checks if URL is relative, prepends relative part if missed
package api
import (
	"encoding/json"
	"fmt"
	"io"
	"net/url"
	"reflect"
	"strings"
)
func TrimMultiline(multi string) string {
	res := ""
	for _, line := range strings.Split(multi, "\n") {
		res += strings.Trim(line, "\t")
	}
	return res
}
func NormalizeODataItem(payload []byte) []byte {
	v := &struct {
		D map[string]interface{} `json:"d"`
	}{}
	if err := json.Unmarshal(payload, &v); err != nil {
		return payload
	}
	if len(v.D) == 0 {
		return payload
	}
	v.D = normalizeMultiLookupsMap(v.D)
	res, _ := json.Marshal(v.D)
	return res
}
func NormalizeODataCollection(payload []byte) ([]byte, string) {
	bb, nextURL := normalizeODataCollection(payload)
	var mapRes []map[string]interface{}
	for _, b := range bb {
		mapItem := map[string]interface{}{}
		if err := json.Unmarshal(b, &mapItem); err == nil {
			mapRes = append(mapRes, normalizeMultiLookupsMap(mapItem))
		}
	}
	res, err := json.Marshal(mapRes)
	if err != nil {
		return payload, nextURL
	}
	return res, nextURL
}
func ExtractEntityURI(payload []byte) string {
	payload = NormalizeODataItem(payload)
	r := &struct {
		Metadata *struct {
			ID string `json:"id"`
		} `json:"__metadata"`
		ID string `json:"odata.id"`
	}{}
	entityURI := ""
	if err := json.Unmarshal(payload, &r); err == nil {
		entityURI = r.ID
	}
	if r.Metadata != nil && r.Metadata.ID != "" {
		entityURI = r.Metadata.ID
	}
	return entityURI
}
func getConfHeaders(config *RequestConfig) map[string]string {
	headers := map[string]string{}
	if config != nil {
		headers = config.Headers
	}
	return headers
}
func patchConfigHeaders(config *RequestConfig, headers map[string]string) *RequestConfig {
	conf := &RequestConfig{}
	if config != nil {
		conf.Context = config.Context
		conf.Headers = config.Headers
	}
	if conf.Headers == nil {
		conf.Headers = map[string]string{}
	}
	for k, v := range headers {
		conf.Headers[k] = v
	}
	return conf
}
func getRelativeURL(absURL string) string {
	u, _ := url.Parse(absURL)
	return u.Path
}