Forum Discussion

Doc-tan's avatar
Doc-tan
Regular Visitor
6 months ago
Solved

Custom connector API - TOKEN (error binary)

I have create a custom connector but i can not see and use the token because of error Details: "We cannot convert a value of type Binary to type Text." at the postman i can post the same url wi...
  • Doc-tan's avatar
    6 months ago

    I solved my problem with putting url, header and body in vars and used these in web.contents.

     

    let
                            creds = Extension.CurrentCredential(),
                            urlToken = Server &"SignIn",
                           
                            HeadersToken = [#"Content-Type" = "application/json",#"api-version" = "1.0"],
                            BodyToken = Json.FromValue([
                                                    username = creds[Username],
                                                    password = creds[Password],
                                                    afm = "",
                                                    code = ""
                                                    ]),


                            ResponseToken =
                             
                                Web.Contents(
                                        url,
                                        [
                                           Headers = HeadersToken ,
                                           Content = BodyToken
                                       
                                        ]
                                            ),
                            JsonResponseToken = Json.Document(ResponseToken),
                            Token =  JsonResponseToken[token]
                         
                       
                        in
                       
                        Token
     
     
    Thank for all your answers!!