web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Unable to parse JSON f...
Copilot Studio
Unanswered

Unable to parse JSON from HTTP request

(0) ShareShare
ReportReport
Posted on by 17

Hello,

 

using a HTTP request that returns a simple JSON string. Regardless of how I tried to return the JSON i am always getting the following message :

 

Error Message: The provided value for path ‘Topic.Var1’ cannot be parsed into ‘RecordDataType’ type. Provided value: “{”“msg”“:”“Welcome, how can i help you ?”“,”“name”“:”“”“,”“timestamp”“:1700574123}” Error Code: ValueParsingError Conversation Id: 0b50d6ad-54f9-4884-9823-04a737136450 Time (UTC): 2023-11-21T13:42:03.078Z

 

For simplicity, The JSON response does not require any headers and/or body data to be returned, it is always returned on every request.

 

This is the JSON string :

 

{"msg":"Welcome, how can i help you ?","name":"alexggg","timestamp":1700574256}

 

What do I need to adjust in order to make this work ? 

 

Thank you for your help.

 

 

Annotation 2023-11-20 140728.png

I have the same question (0)
  • HenryJammes Profile Picture
    on at

    Did you edit the schema?

     

    You can do that easily by selecting "From sample data" in "Response data type" :

    HenryJammes_0-1700575461305.png

    Pasting the JSON here:

    HenryJammes_1-1700575492416.png

    Will generate the following schema:

    HenryJammes_2-1700575510881.png

     

     

     

     

  • GTMRA Profile Picture
    17 on at

    Thanks for the reply, thats how i already configured the response, via the sample data.

  • HenryJammes Profile Picture
    on at

    Can you share the schema?

    Or the full topic YAML?

  • GTMRA Profile Picture
    17 on at

    how can i share it with you ?

  • HenryJammes Profile Picture
    on at

    Can you paste it here or send it as attachment, perhaps over private message?

  • GTMRA Profile Picture
    17 on at

    here is the YAML file.

    kind: AdaptiveDialog
    beginDialog:
     kind: OnConversationStart
     id: main
     actions:
     - kind: SendActivity
     id: sendActivity_xPPdyN
     activity: Hello, I'm {System.Bot.Name}. I am a virtual agent.
    
     - kind: Question
     id: question_WRJgdJ
     interruptionPolicy:
     allowInterruption: true
    
     variable: init:Global.PersonName
     prompt: What is your name ?
     entity: PersonNamePrebuiltEntity
    
     - kind: Question
     id: question_8mECkK
     interruptionPolicy:
     allowInterruption: true
    
     variable: init:Global.WhatToDo
     prompt: |-
     Welcome to the chat, {Global.PersonName}.
     
     What would you like to do?
     entity:
     kind: EmbeddedEntity
     definition:
     kind: ClosedListEntity
     items:
     - id: Chat with an agent
     displayName: Chat with an agent
    
     - id: Book an appointment
     displayName: Book an appointment
    
     - id: JSON
     displayName: JSON
    
     - kind: ConditionGroup
     id: conditionGroup_YSBOAU
     conditions:
     - id: conditionItem_KTHAdC
     condition: =Global.WhatToDo = 'cr437_testBot.topic.ConversationStart.main.question_8mECkK'.'Chat with an agent'
     actions:
     - kind: SendActivity
     id: sendActivity_7gMyb9
     activity: " Connecting you with an agent {Global.PersonName}, please hold on..."
    
     - kind: TransferConversationV2
     id: lyokrx
     transferType:
     kind: TransferToAgent
     messageToAgent: test
    
     - id: conditionItem_zx15MA
     condition: =Global.WhatToDo = 'cr437_testBot.topic.ConversationStart.main.question_8mECkK'.'Book an appointment'
     actions:
     - kind: SendActivity
     id: sendActivity_nACezM
     activity: link to book an appointment
    
     - id: conditionItem_qe25v3
     condition: =Global.WhatToDo = 'cr437_testBot.topic.ConversationStart.main.question_8mECkK'.JSON
     actions:
     - kind: HttpRequestAction
     id: xg1CKA
     url: https://chatapp.azurewebsites.net/chat.php
     response: Topic.Var1
     responseSchema:
     kind: Record
     properties:
     msg: String
     name: String
     timestamp: Number
    
     - kind: SendActivity
     id: sendActivity_BAtywk
     activity: response
  • HenryJammes Profile Picture
    on at

    I can't repro, I guess because I don't have access to the API.

    Error Message: HTTP request failed with status code 403 Forbidden. Error Code: HttpRequestFailure Conversation Id: ba2ff1c9-382c-4939-ac82-91bb35f20b8b Time (UTC): 2023-11-21T14:36:37.860Z

     

    Are you use the API returns a clean JSON? What does the GET request look like when you open https://chatapp.azurewebsites.net/chat.php in your browser or in Postman?

  • HenryJammes Profile Picture
    on at

    Thanks @GTMRA 

     

    I think you get this error because your API returns your JSON as text/html; charset=utf-8 and not as JSON (I was initially puzzled in Postman as it wouldn't format the content nicely).

     

    To work around this, you can switch to the code editor view and update your HTTP request node to set the responseSchema to Any

     

    HenryJammes_0-1700579685052.png

     

    You can then parse it with the desired schema in a subsequent Parse value node:

     

    HenryJammes_1-1700579711173.png

     

    HenryJammes_2-1700579720676.png

    And it now works:

     

    HenryJammes_4-1700579746208.png

     

     

    HenryJammes_3-1700579738093.png

     

  • Verified answer
    GTMRA Profile Picture
    17 on at

    Thank you for your help. The headers were incorrect and needed to be set to :

     

    Content-Type: application/json; charset=utf8

     

  • HimanshuKat Profile Picture
    5 on at

    Same issue, tried with above solution. didnt work

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Copilot Studio

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 265 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 240 Super User 2025 Season 2

#3
S-Venkadesh Profile Picture

S-Venkadesh 101 Moderator

Last 30 days Overall leaderboard